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

Building golang.org/x/tools/cmd/goimports results in error: undefined: ast.Unparen #69391

Closed
dawiddzhafarov opened this issue Sep 11, 2024 · 5 comments

Comments

@dawiddzhafarov
Copy link

What version of Go are you using (go version)?

$ go version
go version go1.22.5 darwin/arm64

Does this issue reproduce with the latest release?

N/A

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE='on'
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/ddzhafar/Library/Caches/go-build'
GOENV='/Users/ddzhafar/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/ddzhafar/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/ddzhafar/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.5'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOWORK='/Users/ddzhafar/projects/go.work'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/39/n67pv3xs007clqj140pcl1km0000gq/T/go-build180051799=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOROOT/bin/go version: go version go1.22.5 darwin/arm64
GOROOT/bin/go tool compile -V: compile version go1.22.5
uname -v: Darwin Kernel Version 23.5.0: Wed May  1 20:13:18 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6030
ProductName:		macOS
ProductVersion:		14.5
BuildVersion:		23F79
lldb --version: lldb-1500.0.404.7
Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)

What did you do?

Having this in the Makefile:

$(BIN):
	@mkdir -p $@
$(BIN)/%: | $(BIN) ; $(info $(M) Building $(PACKAGE)...)
	$Q tmp=$$(mktemp -d); \
	   env GO111MODULE=off GOPATH=$$tmp GOBIN=$(BIN) $(GO) get $(PACKAGE) \
		|| ret=$$?; \
	   rm -rf $$tmp ; exit $$ret

GOIMPORTS = $(BIN)/goimports
$(BIN)/goimports: PACKAGE=golang.org/x/tools/cmd/goimports

After release of v0.25.0 goimports, it fails with:

> Building golang.org/x/tools/cmd/goimports...
# golang.org/x/tools/go/ast/astutil
/tmp/tmp.o0felz6q7F/src/golang.org/x/tools/go/ast/astutil/util.go:11:48: undefined: ast.Unparen 

What did you expect to see?

Expected not to see the error above.

What did you see instead?

Saw the error which crashes the script I'm using. Rolling back to v0.24.0 and the issue is not there.

@seankhliao
Copy link
Member

I don't think this is using go1.22 ?
The given command uses GOPATH mode, but 1.22 should error with a message like:

go: go.mod file not found in current directory or any parent directory.
	'go get' is no longer supported outside a module.
	To build and install a command, use 'go install' with a version,
	like 'go install example.com/cmd@latest'
	For more information, see https://golang.org/doc/go-get-install-deprecation
	or run 'go help get' or 'go help install'.

@seankhliao
Copy link
Member

The function in the error message also says it's available in 1.22 https://pkg.go.dev/go/ast#Unparen

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Sep 11, 2024
@dawiddzhafarov
Copy link
Author

Yes, sorry for the confusion. The version is 1.21.12

$ go version
go version go1.21.12 darwin/arm64

@ianlancetaylor
Copy link
Member

The currently supported versions of Go are 1.22 and 1.23. To build the most recent versions of x/tools requires at least Go 1.22.

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

No branches or pull requests

4 participants