当我运行以下命令时:- go build -o app
,我收到以下错误(针对多个依赖项):main.go:21:2: cannot find package "github.com/gorilla/mux" in any of:
/usr/local/go/src/github.com/gorilla/mux (from $GOROOT)
/go/src/github.com/gorilla/mux (from $GOPATH)
/codebuild/output/src324986171/src/github.com/gorilla/mux
意味着代码构建失败。我知道如何解决这个问题,或者总的来说问题出在哪里? 感谢您的帮助。
编辑:
将go get ./...
添加到内部版本后,我的所有本地软件包都收到以下错误消息:# cd .; git clone https://github.com/aristotle/dbhelper /go/src/github.com/aristotle/dbhelper
Cloning into '/go/src/github.com/aristotle/dbhelper'...
我的buildspec.yml看起来像这样:
version: 0.2
phases:
install:
commands:
- echo CODEBUILD_SRC_DIR - $CODEBUILD_SRC_DIR
- echo GOPATH - $GOPATH
- echo GOROOT - $GOROOT
build:
commands:
- echo Build started on `date`
- echo Getting packages
- go get ./...
- echo Compiling the Go code...
- go build -o app main.go
post_build:
commands:
- echo Build completed on `date`
artifacts:
files:
- app
答案 0 :(得分:0)
根据本文,您需要将其添加到install
文件的buildspec.yml
部分。
install:
commands:
- go get github.com/gorilla/mux
包括go get ./...
也许也可以解决所有依赖关系...但是,如果您没有太多依赖关系,则最好明确列出它们。
这是源文章:https://www.contributing.md/2017/06/30/golang-with-aws-codebuild/