I am wondering what is going on with my local build? I want to test deployment to DEV to fix problem, but I can’t build. make 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
Same with building the 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
It would be nice to resolve the odd issue related to the package setup and vendor/Gopkg.toml/lock being in the parent folder. we should use go mod as this is going to be the standard moving forward just, I had trouble using it with the directory structure for some reason.
You should be able to fix that case by running go mod tidy (with either Go 1.15. 8 or Go 1.16), or by setting -mod=mod explicitly (perhaps as GOFLAGS=-mod=mod ).
A go. mod file is required for the main module, and for any replacement module specified with a local file path. However, a module that lacks an explicit go. mod file may still be required as a dependency, or used as a replacement specified with a module path and version; see Compatibility with non-module repositories.
You can upgrade or downgrade a dependency module by using Go tools to discover available versions, then add a different version as a dependency. To discover new versions use the go list command as described in Discovering available updates.
Go modules commonly consist of one project or library and contain a collection of Go packages that are then released together. Go modules solve many problems with GOPATH , the original system, by allowing users to put their project code in their chosen directory and specify versions of dependencies for each module.
I found the same issue before, and I sovled this issue, change environment variables, GO111MODULE
from on
to auto
Open up File/Preferences/Settings and search for “go tools env vars”
Click “Edit in settings.json” and set GO111MODULE to auto
(instructions from https://dev.to/codeboten/disabling-go-modules-in-visual-studio-code-31mp)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With