gpt4 book ai didi

Golang 找不到模块提供包 {PACKAGE_NAME} : working directory is not part of a module

转载 作者:行者123 更新时间:2023-12-01 22:05:52 25 4
gpt4 key购买 nike

我想知道我的本地构建发生了什么?我想测试部署到 DEV 以解决问题,但我无法构建。
使构建-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来自 onauto打开文件/首选项/设置并搜索“go tools env vars”
单击“在 settings.json 中编辑”并将 GO111MODULE 设置为 auto(来自 https://dev.to/codeboten/disabling-go-modules-in-visual-studio-code-31mp 的说明)

关于Golang 找不到模块提供包 {PACKAGE_NAME} : working directory is not part of a module,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61921282/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com