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 missing go directive in a go.mod #317

Open
alexandear opened this issue Nov 26, 2024 · 0 comments · May be fixed by #318
Open

Panic when missing go directive in a go.mod #317

alexandear opened this issue Nov 26, 2024 · 0 comments · May be fixed by #318

Comments

@alexandear
Copy link

gofumpt panics when the go directive is missing in a go.mod file.

For example, we get a panic when trying to run gofumpt on the repo google/uuid (latest v1.6.0), which doesn't have the go directive in it.

❯ go run mvdan.cc/gofumpt@latest -w .
panic: invalid Go version: "go"

goroutine 6 [running]:
mvdan.cc/gofumpt/format.File(0x14000288000, 0x1400029e000, {{0x100348354, 0x2}, {0x140000146a8, 0x16}, 0x0})
        /Users/Oleksandr_Redko/go/pkg/mod/mvdan.cc/[email protected]/format/format.go:99 +0x23c
main.processFile({0x140001ce498, 0x6}, {0x1003f1068, 0x140001da270}, {0x0?, 0x0?}, 0x14000028f20, 0x0)
        /Users/Oleksandr_Redko/go/pkg/mod/mvdan.cc/[email protected]/gofmt.go:313 +0x23c
main.gofmtMain.func4.1(0x0?)
        /Users/Oleksandr_Redko/go/pkg/mod/mvdan.cc/[email protected]/gofmt.go:529 +0x40
main.(*sequencer).Add.func2()
        /Users/Oleksandr_Redko/go/pkg/mod/mvdan.cc/[email protected]/gofmt.go:191 +0x48
created by main.(*sequencer).Add in goroutine 1
        /Users/Oleksandr_Redko/go/pkg/mod/mvdan.cc/[email protected]/gofmt.go:190 +0x1a8
exit status 2

The documentation states, that "If the go directive is missing, go 1.16 is assumed".

@alexandear alexandear linked a pull request Nov 26, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant