构建aws-sdk-go的依赖关系在Go版本1.13上失败
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了构建aws-sdk-go的依赖关系在Go版本1.13上失败相关的知识,希望对你有一定的参考价值。
我一直在尝试在Go v1.13上构建一个模块,该模块依赖于github.com/aws/aws-lambda-go
和github.com/aws/aws-sdk-go
,这在两次导入时均失败:
"github.com/aws/aws-sdk-go/aws/service/s3"
"github.com/aws/aws-sdk-go/aws/service/s3/s3manager"
对于GOOS=linux GOARCH=amd64 go build -o dist/api ./api
,stderr如下,其中api
目录包含我的模块定义:
api/main.go:11:2: cannot find package "github.com/aws/aws-sdk-go/aws/service/s3" in any of:
/usr/local/go/src/github.com/aws/aws-sdk-go/aws/service/s3 (from $GOROOT)
/u/go/src/github.com/aws/aws-sdk-go/aws/service/s3 (from $GOPATH)
api/main.go:12:2: cannot find package "github.com/aws/aws-sdk-go/aws/service/s3/s3manager" in any of:
/usr/local/go/src/github.com/aws/aws-sdk-go/aws/service/s3/s3manager (from $GOROOT)
/u/go/src/github.com/aws/aws-sdk-go/aws/service/s3/s3manager (from $GOPATH)
老实说,我不知道为什么会这样,任何输入都会受到赞赏。
已经尝试使用go get
来确保已删除依赖项:
$ go get github.com/aws/aws-sdk-go
并且所请求的导入路径位于$GOPATH/src/github.com/aws/aws-sdk/go/aws/service/s3
和$GOPATH/src/github.com/aws/aws-sdk/go/aws/service/s3/s3manager
下
此外,还尝试使用go clean --cache --modcache
清除缓存,同时删除先前拉出的模块。
[仔细检查,我完全忽略了一点,导入路径是/u/go/src/github.com/aws/aws-sdk-go/aws/service/s3
而不是/u/go/src/github.com/aws/aws-sdk-go/service/s3
,而前者在aws
内有一个附加的aws-sdk-go
子路径。
答案
刚刚意识到我在代码中犯的复制/粘贴错误。
import (
"github.com/aws/aws-sdk-go/aws/service/s3"
"github.com/aws/aws-sdk-go/aws/service/s3/s3manager"
)
而不是
import (
"github.com/aws/aws-sdk-go/service/s3"
"github.com/aws/aws-sdk-go/service/s3/s3manager"
)
以上是关于构建aws-sdk-go的依赖关系在Go版本1.13上失败的主要内容,如果未能解决你的问题,请参考以下文章