Skip to content

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

@neclepsio

Description

@neclepsio

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    GoCommandcmd/goNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Proposal

    Type

    No type

    Projects

    Status

    Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions