Hi all,
I’m getting a werid go fmt -w -s output. Has anyone experiences this? The line before a multi-line is not aligned properly in a struct list. In my case, my inID
is way off the column alignments, consistently.
Is this a valid bug?
What version of Go are you using (go version
)?
$ go version go version go1.12.1 linux/amd64
Does this issue reproduce with the latest release?
Yet to explore 1.12.3 just release
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env GOARCH="amd64" GOBIN="/home/u0/bin" GOCACHE="/home/u0/.cache/go-build" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="/home/u0" GOPROXY="" GORACE="" GOROOT="/usr/local/go" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" GCCGO="gccgo" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/home/u0/Documents/gosandbox/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-build565099213=/tmp/go-build -gno-record-gcc-switches"
What did you do?
When applying $ gofmt -w -s .
to the source code, the line before a multi-line was formatted into a weird, not aligning to the correct column. It is very consistent for all the lines right before their respective next multi-lines code.
It happens when I was working on a large struct list for table-driven testing. No issue with execution.
What did you expect to see?
{
inID: 0,
inAction: (AsymmetricEncryptAction |
AsymmetricDecryptAction),
inBadRand: false,
outError: false,
outPublicKey: true,
outPrivateKey: true,
}, {
inID: 1,
inAction: AsymmetricEncryptAction,
inBadRand: false,
outError: false,
outPublicKey: true,
outPrivateKey: true,
}, {
inID: 2,
inAction: AsymmetricDecryptAction,
inBadRand: false,
outError: false,
outPublicKey: true,
outPrivateKey: true,
}, {
inID: 3,
inAction: SignAction | VerifyAction,
inBadRand: false,
outError: false,
outPublicKey: true,
outPrivateKey: true,
What did you see instead?
{
inID: 0,
inAction: (AsymmetricEncryptAction |
AsymmetricDecryptAction),
inBadRand: false,
outError: false,
outPublicKey: true,
outPrivateKey: true,
}, {
inID: 1,
inAction: AsymmetricEncryptAction,
inBadRand: false,
outError: false,
outPublicKey: true,
outPrivateKey: true,
}, {
inID: 2,
inAction: AsymmetricDecryptAction,
inBadRand: false,
outError: false,
outPublicKey: true,
outPrivateKey: true,
}, {
inID: 3,
inAction: SignAction | VerifyAction,
inBadRand: false,
outError: false,
outPublicKey: true,
outPrivateKey: true,