The reason I came to this conclusion is because a build I triggered failed after running make check which includes installing and using the staticcheck binary.
If I'm wrong feel free to let me know and close this issue.
For context,
I triggered the build #230 on 11th May 2020 which failed, there was an issue with staticcheck.
Looking at the build history of all pull requests the last build before mine was build #229 was successful. It didn't have a issue with staticcheck and it was 17 days ago.
Reproducing the Error (Local Machine)
I then decided to reproduce the error on my local machine by running
$ gvm use go1.12.17
$ mkdir -p $GOPATH/src/github.com/heptiolabs
$ cd $GOPATH/src/github.com/heptiolabs
$ git clone https://github.com/kdevu/gangway.git
$ cd gangway
$ make setup && make deps && make bindata
$ make check
Notes
I made sure to that the staticcheck was not installed beforehand
I made sure that the $GOPATH/src/honnef.co directory did not exist beforehand
I used the commands/versions based on what config file the travis build used
language: go
go_import_path: github.com/heptiolabs/gangway
go:
- 1.12.x
sudo: false
install:
- make setup && make deps && make bindata
script:
- make check
Troubleshooting the Error
The error outputted by make check is below. You can see that -unused.whole-program flag doesn't exist in the staticcheck version being used.
Checking code is gofmted
staticcheck -unused.whole-program github.com/heptiolabs/gangway/cmd/gangway github.com/heptiolabs/gangway/internal/config github.com/heptiolabs/gangway/internal/oidc github.com/heptiolabs/gangway/internal/session
flag provided but not defined: -unused.whole-program
Usage of staticcheck:
staticcheck [flags] # runs on package in current directory
staticcheck [flags] packages
staticcheck [flags] directory
staticcheck [flags] files... # must be a single package
Flags:
-checks checks
Comma-separated list of checks to enable. (default "inherit")
-debug.cpuprofile file
Write CPU profile to file
-debug.measure-analyzers file
Write analysis measurements to file. `file` will be opened for appending if it already exists.
-debug.memprofile file
Write memory profile to file
-debug.no-compile-errors
Don't print compile errors
-debug.unused-graph file
Write unused's object graph to file
-debug.version
Print detailed version information about this program
-explain check
Print description of check
-f format
Output format (valid choices are 'stylish', 'text' and 'json') (default "text")
-fail checks
Comma-separated list of checks that can cause a non-zero exit status. (default "all")
-go version
Target Go version in the format '1.x' (default 1.12)
-show-ignored
Don't filter ignored problems
-tags build tags
List of build tags
-tests
Include tests (default true)
-version
Print version and exit
Makefile:51: recipe for target 'staticcheck' failed
make: *** [staticcheck] Error 2
The command "make check" exited with 2.
It seems that the master branch of staticcheck is being used by default
cd $GOPATH/src/honnef.co/go/tools/cmd/staticcheck
git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean
Fixing the issue (Local Machine)
I fixed the issue by running the following commands
$ cd $GOPATH/src/honnef.co/go/tools/cmd/staticcheck
$ git checkout 2020.1.3
$ go get
$ go install
$ staticcheck -version
staticcheck 2020.1.3
Now, I can see that the -unused.whole-program flag now exists
$ staticcheck --help
Usage of staticcheck:
staticcheck [flags] # runs on package in current directory
staticcheck [flags] packages
staticcheck [flags] directory
staticcheck [flags] files... # must be a single package
Flags:
-checks checks
Comma-separated list of checks to enable. (default "inherit")
-debug.cpuprofile file
Write CPU profile to file
-debug.measure-analyzers file
Write analysis measurements to file. `file` will be opened for appending if it already exists.
-debug.memprofile file
Write memory profile to file
-debug.no-compile-errors
Don't print compile errors
-debug.repeat-analyzers num
Run analyzers num times
-debug.unused-graph file
Write unused's object graph to file
-debug.version
Print detailed version information about this program
-explain check
Print description of check
-f format
Output format (valid choices are 'stylish', 'text' and 'json') (default "text")
-fail checks
Comma-separated list of checks that can cause a non-zero exit status. (default "all")
-go version
Target Go version in the format '1.x' (default 1.12)
-show-ignored
Don't filter ignored problems
-tags build tags
List of build tags
-tests
Include tests (default true)
-unused.whole-program
Run unused in whole program mode
-version
Print version and exit
and make check seems to run successfully
$ make check
go test -v ./...
=== RUN TestHomeHandler
--- PASS: TestHomeHandler (0.00s)
=== RUN TestCallbackHandler
=== RUN TestCallbackHandler/default
--- PASS: TestCallbackHandler (0.05s)
--- PASS: TestCallbackHandler/default (0.05s)
=== RUN TestCommandLineHandler
=== RUN TestCommandLineHandler/default
time="2020-05-11T15:35:31+01:00" level=error msg="Failed to open CA file. open : no such file or directory"
time="2020-05-11T15:35:31+01:00" level=warning msg="Could not read CA file: invalid argument"
time="2020-05-11T15:35:31+01:00" level=warning msg="using the Email Claim config setting is deprecated. Gangway uses `UsernameClaim@ClusterName`. This field will be removed in a future version."
time="2020-05-11T15:35:31+01:00" level=warning msg="Setting an empty Client Secret should only be done if you have no other option and is an inherent security risk."
=== RUN TestCommandLineHandler/incorrect_username_claim
time="2020-05-11T15:35:31+01:00" level=error msg="Failed to open CA file. open : no such file or directory"
time="2020-05-11T15:35:31+01:00" level=warning msg="Could not read CA file: invalid argument"
=== RUN TestCommandLineHandler/no_email_claim
time="2020-05-11T15:35:31+01:00" level=error msg="Failed to open CA file. open : no such file or directory"
time="2020-05-11T15:35:31+01:00" level=warning msg="Could not read CA file: invalid argument"
time="2020-05-11T15:35:31+01:00" level=warning msg="Setting an empty Client Secret should only be done if you have no other option and is an inherent security risk."
--- PASS: TestCommandLineHandler (0.03s)
--- PASS: TestCommandLineHandler/default (0.01s)
--- PASS: TestCommandLineHandler/incorrect_username_claim (0.01s)
--- PASS: TestCommandLineHandler/no_email_claim (0.01s)
=== RUN TestKubeconfigHandler
=== RUN TestKubeconfigHandler/default
--- PASS: TestKubeconfigHandler (0.01s)
--- PASS: TestKubeconfigHandler/default (0.01s)
=== RUN TestUnauthedCommandlineHandlerRedirect
--- PASS: TestUnauthedCommandlineHandlerRedirect (0.02s)
PASS
ok github.com/heptiolabs/gangway/cmd/gangway (cached)
=== RUN TestConfigNotFound
--- PASS: TestConfigNotFound (0.00s)
=== RUN TestEnvionmentOverrides
--- PASS: TestEnvionmentOverrides (0.00s)
=== RUN TestGetRootPathPrefix
=== RUN TestGetRootPathPrefix/not_specified
=== RUN TestGetRootPathPrefix/specified
=== RUN TestGetRootPathPrefix/specified_default
--- PASS: TestGetRootPathPrefix (0.00s)
--- PASS: TestGetRootPathPrefix/not_specified (0.00s)
--- PASS: TestGetRootPathPrefix/specified (0.00s)
--- PASS: TestGetRootPathPrefix/specified_default (0.00s)
PASS
ok github.com/heptiolabs/gangway/internal/config (cached)
=== RUN TestParseToken
=== RUN TestParseToken/rsa
=== RUN TestParseToken/default
--- PASS: TestParseToken (0.00s)
--- PASS: TestParseToken/rsa (0.00s)
--- PASS: TestParseToken/default (0.00s)
PASS
ok github.com/heptiolabs/gangway/internal/oidc (cached)
=== RUN TestGenerateSessionKeys
--- PASS: TestGenerateSessionKeys (0.05s)
=== RUN TestInitSessionStore
--- PASS: TestInitSessionStore (0.05s)
=== RUN TestCleanupSession
--- PASS: TestCleanupSession (0.05s)
=== RUN TestJoinSectionCookies
--- PASS: TestJoinSectionCookies (0.00s)
=== RUN TestJoinSectionCookiesSingle
--- PASS: TestJoinSectionCookiesSingle (0.00s)
=== RUN TestSplitCookie
--- PASS: TestSplitCookie (0.00s)
=== RUN TestSplitCookieSingle
--- PASS: TestSplitCookieSingle (0.00s)
=== RUN TestSplitCookieSize
--- PASS: TestSplitCookieSize (0.00s)
=== RUN TestSplitAndJoin
--- PASS: TestSplitAndJoin (0.00s)
PASS
ok github.com/heptiolabs/gangway/internal/session (cached)
go vet ./...
Checking code is gofmted
staticcheck -unused.whole-program github.com/heptiolabs/gangway/cmd/gangway github.com/heptiolabs/gangway/internal/config github.com/heptiolabs/gangway/internal/oidc github.com/heptiolabs/gangway/internal/session
misspell \
-i clas \
-locale US \
-error \
cmd/* docs/* *.md
Long story short, as suggested in documentation https://staticcheck.io/docs/#installation. I believe the line that fetches and installs the
staticcheck
binary (I believe it's this line https://github.com/heptiolabs/gangway/blob/master/Makefile#L51) as part ofmake check
should be modified to use the latest release branch rather than the master branch.The reason I came to this conclusion is because a build I triggered failed after running
make check
which includes installing and using thestaticcheck
binary.If I'm wrong feel free to let me know and close this issue.
For context,
staticcheck
.staticcheck
and it was 17 days ago.Reproducing the Error (Local Machine)
I then decided to reproduce the error on my local machine by running
Notes
staticcheck
was not installed beforehand$GOPATH/src/honnef.co
directory did not exist beforehandTroubleshooting the Error
The error outputted by
make check
is below. You can see that-unused.whole-program
flag doesn't exist in thestaticcheck
version being used.I checked the staticcheck version that I believe is installed by
go get honnef.co/go/tools/cmd/staticcheck
(this line: https://github.com/heptiolabs/gangway/blob/master/Makefile#L51)It seems that the master branch of staticcheck is being used by default
Fixing the issue (Local Machine)
I fixed the issue by running the following commands
Now, I can see that the
-unused.whole-program
flag now existsand
make check
seems to run successfully