go list
reports an error for unknown godebug values. But this error lacks a position:
$ cat go.mod
module example.com/m
go 1.23
godebug foo=1
$ go list .
go: .: unknown godebug "foo"
Compare with the message when there's a syntax error:
> go list .
go: errors parsing go.mod:
go.mod:5: unknown directive: godebg
As a result, gopls does not position this error correctly.
The go command should also position the error correctly in go.work files.
CC @rsc @matloob
Comment From: rsc
Marking release blocker since this should be fairly easy. @matloob or @samthanawalla, want to take a look?
Comment From: gopherbot
Change https://go.dev/cl/588055 mentions this issue: gopls: initial support for godebug directive in go.mod and go.work
Comment From: findleyr
For whomever makes this change: the x/tools tests will likely fail once you fix this, because I've added an assertion for the current default position of this error at the top of the go.mod file. Please ping me, and feel free to skip the failing tests with a -- skip --
file in the test txtar, as here:
https://cs.opensource.google/go/x/tools/+/master:gopls/internal/test/marker/testdata/diagnostics/usemodule.txt;l=6;drc=f6d5f0f1c1c87fb0059d3224c01f0f089aaf6693
Comment From: gopherbot
Change https://go.dev/cl/590135 mentions this issue: cmd/go/internal/modload: add line numbers to godebug errors