Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mention GOFLAGS in documentation as we don't have a -mod flag #506

Open
variadico opened this issue Jun 5, 2019 · 4 comments
Open

Mention GOFLAGS in documentation as we don't have a -mod flag #506

variadico opened this issue Jun 5, 2019 · 4 comments

Comments

@variadico
Copy link

This is more of a documentation ticket. This should probably make its way to the readme or some other document.

staticcheck will fail if you don't have git installed. This is because go list will "helpfully" try to install deps it thinks are missing.

The error looks like this:

$ staticcheck ./...
go [list -e -json -compiled -test=true -export=false -deps=true -find=false -tags= -- ./...]: exit status 1: go: github.com/lib/[email protected]: git init --bare in /root/go/pkg/mod/cache/vcs/01b4997f7dd5821a38fc67ad1dbddb0839f3fe66c76533286b350cb97434f24c: exec: "git": executable file not found in $PATH

If you use go build -mod vendor and have a vendor/ directory, then this will cause you problems. To make the -mod vendor setting global you have to set GOFLAGS.

export GOFLAGS="-mod=vendor"

Then staticcheck will work.

@dominikh
Copy link
Owner

dominikh commented Jun 6, 2019

Noted, we'll mention GOFLAGS in the docs.

See also golang/go#27227 and golang/go#30240

@dominikh dominikh changed the title Doesn't work with mod vendor by default Mention GOFLAGS as we don't have a -mod flag Jun 6, 2019
@dominikh dominikh added this to the v2020.2 milestone Feb 6, 2020
@dominikh dominikh modified the milestones: v2020.2, v2020.3 Jul 24, 2020
@dominikh dominikh removed this from the v2020.3 milestone May 24, 2021
@wallyqs
Copy link

wallyqs commented Oct 4, 2021

GOFLAGS also helps to be able to specify -modfile

GOFLAGS="-mod=mod -modfile=go_test.mod" staticcheck

@variadico variadico changed the title Mention GOFLAGS as we don't have a -mod flag Mention GOFLAGS in documentation as we don't have a -mod flag Oct 7, 2021
@joeshaw
Copy link

joeshaw commented Mar 31, 2022

Is GOFLAGS="-mod=vendor" still required since Go 1.14, which added autodetection of vendoring? https://go.dev/doc/go1.14#vendor

@wallyqs
Copy link

wallyqs commented Mar 31, 2022

If you want to use GOFLAGS="-modfile=go_test.mod" for example, yes would be required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants