【Golang】排查 Build constraints exclude all the go files

877 阅读1分钟

编译报错:排除

Build constraints exclude all the Go files in '/Users/kk/go/pkg/mod/gitlab-ecs.litatom.com/infra/common@v0.0.0-20231122024035-2f328b8eebb2/initialize'

➜  exporter git:(master) ✗ go env | grep -i goos
GOOS="darwin"

➜  exporter git:(master) ✗ go env | grep -i GO111MODULE
GO111MODULE="on"

重建依赖:无效

➜  exporter git:(master) ✗ go mod tidy    

➜  exporter git:(master) ✗ go get -u -v

删除go.mod go.sum,并重建、更新依赖:无效

➜  exporter git:(master) ✗ go mod init x.com/infra/exporter 
go: creating new go.mod: module x.com/infra/exporter
go: to add module requirements and sums:
        go mod tidy
➜  exporter git:(master) ✗ go mod tidy

➜  exporter git:(master) ✗ go get -u  

整体初始化:有效 go mod vendor

➜  exporter git:(master) ✗ go mod tidy

➜  exporter git:(master) ✗ go get -u x.com/infra/common x.com/infra/exporter x.com/infra/inspection x.com/infra/webapp
go: downloading github.com/swaggo/swag v1.16.2
go: downloading github.com/grafana/grafana-api-golang-client v0.26.0
go: upgraded github.com/grafana/grafana-api-golang-client v0.23.0 => v0.26.0
go: upgraded github.com/swaggo/swag v1.16.1 => v1.16.2

➜  exporter git:(master) ✗ go mod tidy

➜  exporter git:(master) ✗ go env -w GO111MODULE=on

➜  exporter git:(master) ✗ go mod tidy

➜  exporter git:(master) ✗ go env -w GOPRIVATE="x.com/infra/common,x.com/infra/webapp,x.com/infra/inspection,x.com/infra/exporter"
➜  exporter git:(master) ✗ go mod tidy

➜  exporter git:(master) ✗ go mod vendor