doucan8521 2018-12-20 13:58
浏览 60

如何修复Go 1.11模块未知导入路径,找不到提供包的模块?

I am building a Go 1.11 Standard App Engine Service.

It's not under GOPATH, so I ran go mod init and go mod tidy.

I am able to build a simple web service using go build, and deploy and test using gcloud app deploy.

I am now trying to add gPubSub code to my service following this code example.

This adds the following imports: "context", "cloud.google.com/go/pubsub".

When I run go build, I get:

../../../../go/pkg/mod/golang.org/x/net@v0.0.0-20181217023233-e147a9138326/idna/idna.go:23:2: unknown import path "golang.org/x/text/secure/bidirule": cannot find module providing package golang.org/x/text/secure/bidirule
../../../../go/pkg/mod/golang.org/x/net@v0.0.0-20181217023233-e147a9138326/idna/idna.go:24:2: unknown import path "golang.org/x/text/unicode/bidi": cannot find module providing package golang.org/x/text/unicode/bidi
../../../../go/pkg/mod/golang.org/x/net@v0.0.0-20181217023233-e147a9138326/idna/idna.go:25:2: unknown import path "golang.org/x/text/unicode/norm": cannot find module providing package golang.org/x/text/unicode/norm

When I run go get -u all, I get "no Go files in"

go build golang.org/x/text/secure/bidirule: no Go files in
go build golang.org/x/text/unicode/bidi: no Go files in
go build golang.org/x/text/unicode/norm: no Go files in

cat go.mod shows me the following: ```

module github.com/XXX/YYY

require (
    cloud.google.com/go v0.34.0
    github.com/googleapis/gax-go v2.0.2+incompatible // indirect
    go.opencensus.io v0.18.0 // indirect
    golang.org/x/net v0.0.0-20181217023233-e147a9138326 // indirect
    golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890 // indirect
    golang.org/x/sync v0.0.0-20181108010431-42b317875d0f // indirect
    golang.org/x/sys v0.0.0-20181218192612-074acd46bca6 // indirect
    google.golang.org/api v0.0.0-20181220000619-583d854617af // indirect
    google.golang.org/appengine v1.3.0 // indirect
    google.golang.org/genproto v0.0.0-20181219182458-5a97ab628bfb // indirect
    google.golang.org/grpc v1.17.0 // indirect
)

```

go list . shows me the following:

go: finding golang.org/x/text/unicode/bidi latest
go: finding golang.org/x/text/secure/bidirule latest
go: finding golang.org/x/text/unicode/norm latest
go: finding golang.org/x/text/unicode latest
go: finding golang.org/x/text/secure latest
github.com/XXX/YYY/ZZZ (our project)

This seems to be some transient dependency.

When I deploy using gcloud app deploy, my service does successfully build and on execution, publishes to the pubsub topic, so this is a local problem.

How do I diagnose and fix this local dev environment problem?

  • 写回答

1条回答 默认 最新

  • duanlu6114 2018-12-20 18:08
    关注

    fixed:

    rm -rf ~/go/pkg/mod/golang.org/x/text@v0.3.0

    go get golang.org/x/text

    评论

报告相同问题?

悬赏问题

  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c