Skip to content

cmd/go: missing position for "unknown godebug" error from go list #67623

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

Closed
findleyr opened this issue May 23, 2024 · 4 comments
Closed

cmd/go: missing position for "unknown godebug" error from go list #67623

findleyr opened this issue May 23, 2024 · 4 comments
Assignees
Labels
GoCommand cmd/go NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Milestone

Comments

@findleyr
Copy link
Member

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

@findleyr findleyr added this to the Go1.23 milestone May 23, 2024
@rsc
Copy link
Contributor

rsc commented May 23, 2024

Marking release blocker since this should be fairly easy. @matloob or @samthanawalla, want to take a look?

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/588055 mentions this issue: gopls: initial support for godebug directive in go.mod and go.work

@findleyr
Copy link
Member Author

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

gopherbot pushed a commit to golang/tools that referenced this issue May 24, 2024
For now, incorporate godebug support by just updating x/mod and write
some tests. Diagnostics are mispositioned due to golang/go#67623.

While writing tests, I realized that the expect package still did not
support go.work files. Add this missing support. Also, remove a stale
comment from go.mod comment extraction, and simplify.

Fixes golang/go#67583

Change-Id: I9d9bb53824b8c817ee18f51a0cfca63842565513
Reviewed-on: https://go-review.googlesource.com/c/tools/+/588055
Reviewed-by: Alan Donovan <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
@cagedmantis cagedmantis added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label May 24, 2024
@matloob matloob added the GoCommand cmd/go label Jun 3, 2024
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/590135 mentions this issue: cmd/go/internal/modload: add line numbers to godebug errors

@matloob matloob added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GoCommand cmd/go NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Projects
Status: Done
Development

No branches or pull requests

5 participants