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

cmd/go: go.mod formatting drops unattached comments within blocks #33280

Open
0xmohit opened this issue Jul 25, 2019 · 3 comments
Open

cmd/go: go.mod formatting drops unattached comments within blocks #33280

0xmohit opened this issue Jul 25, 2019 · 3 comments

Comments

@0xmohit
Copy link
Contributor

@0xmohit 0xmohit commented Jul 25, 2019

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

$ go version
go version go1.13beta1 linux/amd64

Does this issue reproduce with the latest release?

Yes, happens with 1.12.6 too. Not tried with tip.

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/mohit/.cache/go-build"
GOENV="/home/mohit/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/mohit/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go-1.13beta1"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go-1.13beta1/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/tmp/exp/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build485779267=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Executed go mod edit -fmt on the following. (The following is a minimal reproducible example of the actual go.mod file.)

module exp

go 1.13

require (
	foo v0.0.0-00010101000000-000000000000
	// bar v0.0.0-00010101000000-000000000000
)

What did you expect to see?

Perhaps no change.

What did you see instead?

The commented disappeared after formatting.

module exp

go 1.13

require foo v0.0.0-00010101000000-000000000000
@agnivade

This comment has been minimized.

Copy link
Contributor

@agnivade agnivade commented Jul 25, 2019

Btw, your What did you do? section is wrong. The command is go mod edit -fmt, not go mod tidy -fmt as you have correctly mentioned in the title.

@0xmohit

This comment has been minimized.

Copy link
Contributor Author

@0xmohit 0xmohit commented Jul 25, 2019

Btw, your What did you do? section is wrong. The command is go mod edit -fmt, not go mod tidy -fmt as you have correctly mentioned in the title.

It was a typo and was meant to be go mod edit -fmt.

@bcmills bcmills added the modules label Jul 25, 2019
@bcmills bcmills added this to the Go1.14 milestone Jul 25, 2019
@bcmills bcmills changed the title cmd/go: go mod edit -fmt can result in lost comments cmd/go: go.mod formatting drops unattached comments within blocks Sep 16, 2019
@bcmills bcmills added the help wanted label Sep 16, 2019
@bcmills bcmills modified the milestones: Go1.14, Unplanned Sep 16, 2019
@AndersonQ

This comment has been minimized.

Copy link
Contributor

@AndersonQ AndersonQ commented Oct 19, 2019

As it looks stale I'll investigate

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