我想知道本地构建怎么了?我想测试到DEV的部署以解决问题,但无法构建。
使build-mac
env GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w -X main.version=v1.0.20-16-ga0298c0 -X main.commit=a0298c0 -X main.branch=master -X main.buildDate=2020-05-20T11:12:36-0700" -o backend main.go
main.go:7:2: cannot find module providing package github.com/LF-Engineering/vulnerability-detection/backend/cmd: working directory is not part of a module
main.go:8:2: cannot find module providing package github.com/LF-Engineering/vulnerability-detection/backend/v2: working directory is not part of a module
make: *** [build-mac] Error 1
与构建lambda相同:
dep ensure -v
Building a staticlly linked binary...
env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -X main.version=v1.0.20-16-ga0298c0 -X main.commit=a0298c0 -X main.branch=master -X main.buildDate=2020-05-20T11:26:15-0700" -tags aws_lambda -o backend_aws_lambda main.go
main.go:7:2: cannot find module providing package github.com/LF-Engineering/vulnerability-detection/backend/cmd: working directory is not part of a module
main.go:8:2: cannot find module providing package github.com/LF-Engineering/vulnerability-detection/backend/v2: working directory is not part of a module
make: *** [build_aws_lambda] Error 1```
I have done a clean build, removed vendor and re-tried.
Wonder if this is a go version problem? Recently updated:
```go version
go version go1.14.3 darwin/amd64
解决与软件包设置和上级文件夹中的vendor/Gopkg.toml/lock相关的奇怪问题会很好。
我们应该使用go mod,因为这将成为前进的标准
只是,由于某种原因,我无法在目录结构中使用它。
最佳答案
我之前发现了相同的问题,因此解决了这个问题,将环境变量GO111MODULE
从on
更改为auto
关于go - Golang找不到提供软件包{PACKAGE_NAME}的模块: working directory is not part of a module,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/61921282/