Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version)?
go version go1.9.1 linux/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/xxx/go"
GORACE=""
GOROOT="/usr/lib64/go"
GOTOOLDIR="/usr/lib64/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="x86_64-pc-linux-gnu-gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build052197988=/tmp/go-build -gno-record-gcc-switches"
CXX="x86_64-pc-linux-gnu-g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
What did you do?
The following code (https://play.golang.org/p/yWr8ET9ZUg) is laid out with comments as I would expect:
package main
import "os/exec"
func main() {
exec.Command("nmap",
"-sV", // Get version information
"-oA", "blah", // Save all versions as output
"-oG", "-", // Output Greppable format to stdout
"-Pn", // Skip Ping scan to force scanning everything
"-p-", // Scan all ports
"-v", // Increase verbosity (shows down hosts now)
)
}
However, the output of gofmt gives the following (https://play.golang.org/p/My_W9bkZrY):
package main
import "os/exec"
func main() {
exec.Command("nmap",
"-sV", // Get version information
"-oA", "blah", // Save all versions as output
"-oG", "-", // Output Greppable format to stdout
"-Pn", // Skip Ping scan to force scanning everything
"-p-", // Scan all ports
"-v", // Increase verbosity (shows down hosts now)
)
}
It seems to appear that the first two lines are treated as one block, the third line by itself, and the last three lines are treated as another block.
What did you expect to see?
I would expect no change in the formating of the comments
What did you see instead?
The comments changed, as shown above.
First time bug for me, so hopefully this is OK. Let me know if there is anything more you need. I'm also keen to help fix it, but I'm also new to go so may take a while :)
Cheers,
Hugh
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version)?go version go1.9.1 linux/amd64Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env)?What did you do?
The following code (https://play.golang.org/p/yWr8ET9ZUg) is laid out with comments as I would expect:
However, the output of
gofmtgives the following (https://play.golang.org/p/My_W9bkZrY):It seems to appear that the first two lines are treated as one block, the third line by itself, and the last three lines are treated as another block.
What did you expect to see?
I would expect no change in the formating of the comments
What did you see instead?
The comments changed, as shown above.
First time bug for me, so hopefully this is OK. Let me know if there is anything more you need. I'm also keen to help fix it, but I'm also new to go so may take a while :)
Cheers,
Hugh