duandanai6470 2018-12-04 01:50
浏览 83
已采纳

Go模块-无法访问本地软件包?

So, I'm new to Go. I've created a go.mod file

module github.com/austin/test-project <--- This is all I've added to the go.mod

I added a tag v0.0.1 to my commit latest git commit.

Based on some examples I tried to understand, I added these imports to my go file(s), where common is one package, dynamo is another, and the import is from a third package called main.

import (
"github.com/austin/test-project/common"
"github.com/austin/test-project/db/dynamo/playerstateddb"
"github.com/austin/test-project/db/dynamo/characterstateddb"


"context"
"fmt"
"encoding/json"

"github.com/aws/aws-lambda-go/lambda"
"github.com/aws/aws-lambda-go/events"

And here is my output after running go build ./handler/characterstate where the main go file is:

go: finding github.com/aws/aws-lambda-go/events latest
go: finding github.com/aws/aws-lambda-go/lambda latest
go: finding github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute latest
go: finding github.com/aws/aws-sdk-go/service/dynamodb latest
go: finding github.com/aws/aws-sdk-go/aws latest
go: finding github.com/aws/aws-sdk-go/aws/session latest
go: finding github.com/aws/aws-lambda-go v1.7.0
go: downloading github.com/aws/aws-lambda-go v1.7.0
go: finding github.com/aws/aws-sdk-go/service latest
go: finding github.com/aws/aws-sdk-go v1.15.89
go: downloading github.com/aws/aws-sdk-go v1.15.89
go: finding github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8
go: downloading github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8

The go.mod file is now this:

module github.com/carbonated-dev/madworld-backend

require (
    github.com/aws/aws-lambda-go v1.7.0
    github.com/aws/aws-sdk-go v1.15.89
)

... and I have a characterstate.exe at the root, and the expected go.sum

In my IDE, GoLand, the import paths for my local common and dynamo packages are still highlighted red.

I've been searching all day, and I've got no idea what's going on. Where am I going wrong? Could it be that the git repo is private that I'm trying to

Thanks in advance. Hope to hear from someone soon :)

  • 写回答

1条回答 默认 最新

  • douwojiao5919 2018-12-05 22:45
    关注

    Simply and outdated IDE. Once updated to a version that supported Go 1.11, I no longer saw the red error text on import.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 用三极管设计—个共射极放大电路
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示