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/gopls/internal/analysis/modernize: Suggests replacing code in the standard library which provides the modern implementation. #73100

Closed
renthraysk opened this issue Mar 29, 2025 · 5 comments
Labels
BugReport Issues describing a possible bug in the Go implementation. gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@renthraysk
Copy link

Go version

go version go1.24.1 linux/amd64

Output of go env in your module/workspace:

AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/ren/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/ren/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2397105502=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/dev/null'
GOMODCACHE='/home/ren/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/ren/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/ren/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.24.1'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

Open maps/maps.go from the standard library.

What did you see happen?

A suggestion to replace the implementation of maps.Copy() with a call to maps.Copy().

Image

What did you expect to see?

No suggestion.

@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Mar 29, 2025
@gopherbot gopherbot added this to the Unreleased milestone Mar 29, 2025
@gabyhelp
Copy link

Related Issues

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

@gabyhelp gabyhelp added the BugReport Issues describing a possible bug in the Go implementation. label Mar 29, 2025
@xieyuschen
Copy link
Contributor

xieyuschen commented Mar 31, 2025

Hi @renthraysk , I think the modernize has supported this feature already. You can go install golang.org/x/tools/gopls/internal/analysis/modernize and then run modernize -fix <your-pkg> to fix this.

Image

@renthraysk
Copy link
Author

renthraysk commented Mar 31, 2025

Not asking for a feature. It's a bug, modernize suggests changes to maps.Copy()'s implementation that would recurse forever.

@xieyuschen
Copy link
Contributor

xieyuschen commented Mar 31, 2025

Not asking for a feature. It's a bug, modernize suggests changes to maps.Copy()'s implementation that would recurse forever.

Oh, sorry I understand it wrongly and you're talking about maps.Copy itself. I think we should reject these scenarios(maps.Insert and maps.Copy).

Updates: CL 653595 should already support it, but it hasn't been applied to latest yet.

@findleyr
Copy link
Member

Closing as fixed (but not yet released).

@findleyr findleyr modified the milestones: Unreleased, gopls/v0.19.0 Mar 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BugReport Issues describing a possible bug in the Go implementation. gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

5 participants