Skip to content

x/tools/gopls/internal/analysis/modernize: Incorrect fix for map clone #72009

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
silverwind opened this issue Feb 27, 2025 · 1 comment
Closed
Labels
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

@silverwind
Copy link

silverwind commented Feb 27, 2025

Go version

go version go1.24.0 darwin/arm64

Output of go env in your module/workspace:

not relevant

What did you do?

Given this code snippet:

env := append([]string{}, os.Environ()...)

What did you see happen?

Running go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -fix ./... against it changes it to unexpected

env := os.Environ()

What did you expect to see?

env := maps.Clone(os.Environ())

Full example: https://github.com/go-gitea/gitea/pull/33739/files#diff-9eb7ecf3f47cf4bf4925d890d93f44741dbfb744515e9e5b5e159dc02866ebf5

@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 Feb 27, 2025
@gopherbot gopherbot added this to the Unreleased milestone Feb 27, 2025
@silverwind
Copy link
Author

Actually I see this is a slice of strings, which makes no sense to copy, so this is invalid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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

2 participants