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

Panic when running on windows #52

Closed
AvyChanna opened this issue Jun 20, 2024 · 0 comments · Fixed by #53
Closed

Panic when running on windows #52

AvyChanna opened this issue Jun 20, 2024 · 0 comments · Fixed by #53
Labels
bug Something isn't working

Comments

@AvyChanna
Copy link

When not inside a module, GOMOD is set to NUL on windows (instead of /dev/null). This

// From `go help environment` ->
GOMOD
                The absolute path to the go.mod of the main module.
                If module-aware mode is enabled, but there is no go.mod, GOMOD will be
                os.DevNull ("/dev/null" on Unix-like systems, "NUL" on Windows).
                If module-aware mode is disabled, GOMOD will be the empty string.

if goEnv["GOMOD"] == "/dev/null" {

Here's the stacktrace when running with golangci-lint

[runner] Panic stack trace: goroutine 1 [running]:
runtime/debug.Stack()
	C:/Program Files/Go/src/runtime/debug/stack.go:24 +0x5e
github.com/golangci/golangci-lint/pkg/lint.(*Runner).runLinterSafe.func1()
	C:/Users/username/go/pkg/mod/github.com/golangci/golangci-lint@v1.58.2/pkg/lint/runner.go:147 +0x279
panic({0x153b0e0?, 0x220de90?})
	C:/Program Files/Go/src/runtime/panic.go:770 +0x132
github.com/ryancurrah/gomodguard.(*Processor).SetBlockedModules(0xc001e1a438)
	C:/Users/username/go/pkg/mod/github.com/ryancurrah/gomodguard@v1.3.2/processor.go:144 +0x52
github.com/ryancurrah/gomodguard.NewProcessor(0xc000ad0540)
	C:/Users/username/go/pkg/mod/github.com/ryancurrah/gomodguard@v1.3.2/processor.go:66 +0x165
github.com/golangci/golangci-lint/pkg/golinters/gomodguard.New.func1(0xc000738ae0)
	C:/Users/username/go/pkg/mod/github.com/golangci/golangci-lint@v1.58.2/pkg/golinters/gomodguard/gomodguard.go:68 +0x3e
github.com/golangci/golangci-lint/pkg/goanalysis.(*Linter).preRun(0xc000ada540, 0xc000738ae0)
	C:/Users/username/go/pkg/mod/github.com/golangci/golangci-lint@v1.58.2/pkg/goanalysis/linter.go:157 +0xd7
github.com/golangci/golangci-lint/pkg/goanalysis.MetaLinter.Run({{0xc000818200, 0x3c, 0x40}, 0xc0005013e0}, {0x70d880?, 0xc001351f80?}, 0xc000738ae0)
	C:/Users/username/go/pkg/mod/github.com/golangci/golangci-lint@v1.58.2/pkg/goanalysis/metalinter.go:26 +0x85
github.com/golangci/golangci-lint/pkg/lint.(*Runner).runLinterSafe(0xc00121f750?, {0x1970d30?, 0xc000bb1180?}, 0xc000738ae0, 0xc000524380)
	C:/Users/username/go/pkg/mod/github.com/golangci/golangci-lint@v1.58.2/pkg/lint/runner.go:152 +0xb5
github.com/golangci/golangci-lint/pkg/lint.(*Runner).Run.func1()
	C:/Users/username/go/pkg/mod/github.com/golangci/golangci-lint@v1.58.2/pkg/lint/runner.go:120 +0x5b
github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0xc0013105a0, {0x173db39, 0x15}, 0xc00121f958)
	C:/Users/username/go/pkg/mod/github.com/golangci/golangci-lint@v1.58.2/pkg/timeutils/stopwatch.go:111 +0x44
github.com/golangci/golangci-lint/pkg/lint.(*Runner).Run(0xc00130e9c0, {0x1970d30, 0xc000bb1180}, {0xc00012a6e0, 0x1, 0xc0008ce980?})
	C:/Users/username/go/pkg/mod/github.com/golangci/golangci-lint@v1.58.2/pkg/lint/runner.go:119 +0x276
github.com/golangci/golangci-lint/pkg/commands.(*runCommand).runAnalysis(0xc0008c2d80, {0x1970d30, 0xc000bb1180}, {0xc0008ce980, 0x1, 0x4})
	C:/Users/username/go/pkg/mod/github.com/golangci/golangci-lint@v1.58.2/pkg/commands/run.go:390 +0x1f1
github.com/golangci/golangci-lint/pkg/commands.(*runCommand).runAndPrint(0xc0008c2d80, {0x1970d30, 0xc000bb1180}, {0xc0008ce980, 0x1, 0x4})
	C:/Users/username/go/pkg/mod/github.com/golangci/golangci-lint@v1.58.2/pkg/commands/run.go:347 +0x285
github.com/golangci/golangci-lint/pkg/commands.(*runCommand).execute(0xc0008c2d80, 0xc000779b18?, {0xc0008ce980, 0x1, 0x4})
	C:/Users/username/go/pkg/mod/github.com/golangci/golangci-lint@v1.58.2/pkg/commands/run.go:253 +0x1f3
github.com/spf13/cobra.(*Command).execute(0xc000884908, {0xc0008ce940, 0x4, 0x4})
	C:/Users/username/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:944 +0x867
github.com/spf13/cobra.(*Command).ExecuteC(0xc000884308)
	C:/Users/username/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:1068 +0x3a5
github.com/spf13/cobra.(*Command).Execute(...)
	C:/Users/username/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:992
github.com/golangci/golangci-lint/pkg/commands.(*rootCommand).Execute(0xc0008c8930)
	C:/Users/username/go/pkg/mod/github.com/golangci/golangci-lint@v1.58.2/pkg/commands/root.go:83 +0x3d
github.com/golangci/golangci-lint/pkg/commands.Execute({{0x19607d8, 0x8}, {0x19e0baf, 0x7}, {0xc0005cf260, 0x52}, {0x16baf39, 0x9}})
	C:/Users/username/go/pkg/mod/github.com/golangci/golangci-lint@v1.58.2/pkg/commands/root.go:17 +0x5a
main.main()
	C:/Users/username/go/pkg/mod/github.com/golangci/golangci-lint@v1.58.2/cmd/golangci-lint/main.go:24 +0xc5

[runner] Can't run linter goanalysis_metalinter: panic occurred: runtime error: invalid memory address or nil pointer dereference
@ryancurrah ryancurrah added the bug Something isn't working label Jun 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants