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

proposal: cmd/go: 'go mod tidy' should remove stale 'replace' directives #30516

Open
neclepsio opened this issue Mar 1, 2019 · 2 comments

Comments

Projects
None yet
4 participants
@neclepsio
Copy link

commented Mar 1, 2019

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

$ go version
go version go1.12 windows/amd64

Does this issue reproduce with the latest release?

Yes.

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

go env Output
$ go env
set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPROXY=
set GORACE=
set GOTMPDIR=

What did you do?

I created a go.mod file with two replaces in separate lines, then run go mod tidy. foo3 replacement is unused.

replace foo => bar
replace foo2 => bar2
replace foo3 => bar3

What did you expect to see?

A nicely formatted go.mod. Moreover, I think the unused replace should be removed.

replace (
        foo => bar
        foo2 => bar2
)

What did you see instead?

The file is unchanged. Also, go mod edit -fmt does not format replaces.

@gopherbot gopherbot added this to the Proposal milestone Mar 1, 2019

@gopherbot gopherbot added the Proposal label Mar 1, 2019

@bcmills

This comment has been minimized.

Copy link
Member

commented Mar 1, 2019

See also #29813.

@bcmills bcmills changed the title proposal: go mod tidy should reformat replaces proposal: cmd/go: 'go mod tidy' should reformat replaces Mar 1, 2019

@rsc

This comment has been minimized.

Copy link
Contributor

commented Mar 7, 2019

In general we don't override grouping. If you wrote three replace lines, they should stay three separate replace lines. (Especially if there are comments involved, but even if not.)

I will retitle this to be about unused replaces, which are not as clearly off the table. It's tied up with #29813, though, and in general I'm hesitant to make tidy throw away info that might be needed.

@rsc rsc changed the title proposal: cmd/go: 'go mod tidy' should reformat replaces proposal: cmd/go: 'go mod tidy' should remove stale 'replace' directives Mar 7, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.