gci icon indicating copy to clipboard operation
gci copied to clipboard

Fix build failure due to outdated golang.org/x/tools

Open krostar opened this issue 2 months ago • 3 comments

Building gci with recent Go versions fails with the following error:

# golang.org/x/tools/internal/tokeninternal
vendor/golang.org/x/tools/internal/tokeninternal/tokeninternal.go:64:9: invalid array length -delta * delta (constant -256 of type int64)

This issue originates from an outdated version of golang.org/x/tools, which is breaking due to recent changes golang/go#74462.

This PR updates the dependency to the latest version by running:

go get golang.org/x/tools@latest
go mod tidy

krostar avatar Oct 19 '25 19:10 krostar

any updates? @daixiang0

ysomad avatar Nov 04 '25 13:11 ysomad

We can avoid the toolchain bump to 1.24 from 1.21 if we just update the patch version of tools.

diff --git a/go.mod b/go.mod
index 40303bd122..0c2875cbe9 100644
--- a/go.mod
+++ b/go.mod
@@ -4,19 +4,19 @@
 
 require (
 	github.com/hexops/gotextdiff v1.0.3
-	github.com/pmezard/go-difflib v1.0.0
 	github.com/spf13/cobra v1.6.1
 	github.com/stretchr/testify v1.9.0
 	go.uber.org/zap v1.24.0
 	golang.org/x/mod v0.20.0
 	golang.org/x/sync v0.8.0
-	golang.org/x/tools v0.24.0
+	golang.org/x/tools v0.24.1
 	gopkg.in/yaml.v3 v3.0.1
 )
 
 require (
 	github.com/davecgh/go-spew v1.1.1 // indirect
 	github.com/inconshreveable/mousetrap v1.0.1 // indirect
+	github.com/pmezard/go-difflib v1.0.0 // indirect
 	github.com/spf13/pflag v1.0.5 // indirect
 	go.uber.org/atomic v1.7.0 // indirect
 	go.uber.org/multierr v1.6.0 // indirect
diff --git a/go.sum b/go.sum
index 4170441a76..d5b2c694fb 100644
--- a/go.sum
+++ b/go.sum
@@ -31,12 +31,10 @@
 go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg=
 golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0=
 golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
-golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
-golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
 golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
 golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
-golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24=
-golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ=
+golang.org/x/tools v0.24.1 h1:vxuHLTNS3Np5zrYoPRpcheASHX/7KiGo+8Y4ZM1J2O8=
+golang.org/x/tools v0.24.1/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ=
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

meain avatar Nov 12 '25 06:11 meain

Updated using go get -u=patch golang.org/x/tools instead of go get golang.org/x/tools@latest following @meain recommandation, thanks for the feedback

krostar avatar Nov 22 '25 17:11 krostar