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

staticcheck fails locally #590

Open
philippschulte opened this issue Jan 27, 2025 · 1 comment
Open

staticcheck fails locally #590

philippschulte opened this issue Jan 27, 2025 · 1 comment

Comments

@philippschulte
Copy link
Member

staticcheck fails locally maybe releated to #580:

philipp@philipp-XPS-15-9500:~/src/fastly/go-fastly$ GO=go1.20.14 make staticcheck
==> Running staticcheck
staticcheck 2023.1.7 (v0.4.7)
/usr/local/go/src/crypto/subtle/xor.go:12:7: undefined: min (compile)
/usr/local/go/src/runtime/mfixalloc.go:60:9: undefined: max (compile)
/usr/local/go/src/runtime/mgcmark.go:1427:7: undefined: min (compile)
/usr/local/go/src/runtime/mgcpacer.go:1146:15: undefined: max (compile)
/usr/local/go/src/runtime/mgcpacer.go:1156:12: undefined: max (compile)
/usr/local/go/src/runtime/mgcpacer.go:1157:12: undefined: min (compile)
/usr/local/go/src/runtime/mgcscavenge.go:954:10: undefined: min (compile)
/usr/local/go/src/runtime/mpagealloc.go:1059:10: undefined: max (compile)
/usr/local/go/src/runtime/mpallocbits.go:150:10: undefined: max (compile)
/usr/local/go/src/runtime/mpallocbits.go:159:9: undefined: max (compile)
/usr/local/go/src/runtime/runtime1.go:439:25: undefined: min (compile)
/usr/local/go/src/runtime/symtab.go:1174:10: undefined: max (compile)
/usr/local/go/src/runtime/time.go:189:17: cannot range over 3 (untyped int constant) (compile)
/usr/local/go/src/runtime/time.go:1190:11: undefined: min (compile)
/usr/local/go/src/runtime/time.go:1256:37: undefined: min (compile)
make: *** [Makefile:73: staticcheck] Error 1

but passes in CI (https://github.com/fastly/go-fastly/actions/runs/12993241925/job/36234990394):

   with:
    go-version: 1.20.x
    check-latest: false
    token: ***
    cache: true
Setup go version spec 1.20.x
Attempting to download 1.20.x...
matching 1.20.x...
Acquiring 1.20.14 from https://github.com/actions/go-versions/releases/download/1.20.14-7809684997/go-1.20.14-linux-x64.tar.gz
Extracting Go...
  make staticcheck
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
==> Running staticcheck
staticcheck 2023.1.7 (v0.4.7)
@philippschulte philippschulte changed the title Staticchec fails locally staticcheck fails locally Jan 27, 2025
@SahibYar
Copy link
Contributor

Hi Philip,

Thank you for raising this bug! I have a quick question: why is staticcheck ./... attempting to analyze the Go standard library source code (e.g., /usr/local/go/src/...)? This behavior isn’t normal and likely points to an environment issue.

Typically, staticcheck ./... should only analyze the project’s code. However, in this case, it seems to be analyzing the Go standard library, which could potentially be caused by the GO variable interfering with how staticcheck resolves package paths.

To investigate, I tried running it inside a Docker container since I am using a Mac, but I wasn’t able to reproduce the issue:

# GO=go1.20.14 make staticcheck  
==> Running staticcheck  
staticcheck 2023.1.7 (v0.4.7)  

Potential Solution

@kpfleming , would it make sense to update the Makefile to explicitly list only project packages? For example:

@staticcheck $(shell go list ./...)  

Let me know your thoughts!

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

No branches or pull requests

2 participants