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

x/tools/internal/imports: zstdlib.go fails to generate with Go 1.20 #58245

Closed
dmitshur opened this issue Feb 2, 2023 · 1 comment
Closed
Assignees
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@dmitshur
Copy link
Contributor

dmitshur commented Feb 2, 2023

Doing go generate golang.org/x/tools/internal/imports is fine with Go 1.19 and older, but fails when using Go 1.20:

$ go version
go version go1.20 darwin/arm64

$ go generate
2023/02/02 09:41:00 go command exited unsuccessfully: exit status 1
package cmd/api is not a main package
exit status 1
imports.go:5: running "go": exit status 1

The error output shown above was using following patch; the real error output is more inscrutable without it.

 cmd := exec.Command("go"+exeSuffix, "run", "cmd/api", "-contexts", "js-wasm", "syscall/js")
 out, err := cmd.Output()
-if err != nil {
+if ee := (*exec.ExitError)(nil); errors.As(err, &ee) {
+	log.Fatalf("go command exited unsuccessfully: %v\n%s", ee.ProcessState.String(), ee.Stderr)
+} else if err != nil {
 	log.Fatalln(err)
 }

The problem is that CL 453258 rewrote cmd/api to be a package rather than command, since it was more convenient for cmd/dist that way and cmd/api isn't really meant for external use.

It seems straightforward enough not to use of all cmd/api for the purposes of imports. I'll send a fix.

CC @rfindley, @bradfitz.

@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. Tools This label describes issues relating to any tools in the x/tools repository. labels Feb 2, 2023
@dmitshur dmitshur added this to the Unreleased milestone Feb 2, 2023
@dmitshur dmitshur self-assigned this Feb 2, 2023
@gopherbot
Copy link

Change https://go.dev/cl/464715 mentions this issue: internal/imports: use go/packages instead of cmd/api to compute symbols

rinchsan pushed a commit to rinchsan/gosimports that referenced this issue Feb 19, 2023
The API of syscall/js package is generated by reusing cmd/api. That has
stopped being a runnable command after an internal refactor in Go 1.20.
Since cmd/api was never really supported or meant to be used outside of
GOROOT, switch to using go/packages and compute the API more directly
ourselves.

Also use the same approach to generate the API of package unsafe (whose
API is also not present in GOROOT/api files at this time) instead of a
fixed list that needs manual maintenance. This adds Add and Slice that
were added to package unsafe in Go 1.17. It also removes ArbitraryType,
since that symbol isn't a part of package unsafe's API but used in its
documentation—it seems like an oversight that it was added in CL 24463.

This CL intentionally leaves out unsafe's SliceData, String, StringData
that were added in Go 1.20, so I can test out the new relui workflow to
send a CL that regenerates this package.

Fixes golang/go#58245.
For golang/go#38706.

Change-Id: Ibe0d89bf0469691bd16e0d0f501e3762256f2239
Reviewed-on: https://go-review.googlesource.com/c/tools/+/464715
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
@golang golang locked and limited conversation to collaborators Feb 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

2 participants