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

go/format: Struct literal alignment differing between 1.10 and 1.11beta1 #26098

Closed
jacobbednarz opened this issue Jun 27, 2018 · 3 comments
Closed
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@jacobbednarz
Copy link

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

go1.11beta1

Does this issue reproduce with the latest release?

Yes - it appears to only be present in the latest beta release.

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

go env output: https://travis-ci.org/cloudflare/cloudflare-go/jobs/397558038#L444

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/travis/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/travis/gopath"
GOPROXY=""
GORACE=""
GOROOT="/home/travis/.gimme/versions/go1.11beta1.linux.amd64"
GOTMPDIR=""
GOTOOLDIR="/home/travis/.gimme/versions/go1.11beta1.linux.amd64/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="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"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build714400769=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Playground link: https://play.golang.org/p/ccTd61RjEgE (renders go fmt correctly)

What did you expect to see?

package main

import (
	"fmt"
)

type MyStruct struct {
	Test                                    string
	Test1                                   string
	Test2                                   string
	MyReallyLongKeyThatNoOneShouldAlignWith string
}

func main() {
	var myVar = MyStruct{
		Test:  "this is my string",
		Test1: "test1",
		Test2: "test2",
		MyReallyLongKeyThatNoOneShouldAlignWith: "also a string",
	}
	fmt.Println(myVar)
}

What did you see instead?

Failed CI step demonstrating this on beta1 wanting the file to be formatted as below.

package main

import (
	"fmt"
)

type MyStruct struct {
	Test                                    string
	Test1                                   string
	Test2                                   string
	MyReallyLongKeyThatNoOneShouldAlignWith string
}

func main() {
	var myVar = MyStruct{
		Test:                                    "this is my string",
		Test1:                                   "test1",
		Test2:                                   "test2",
		MyReallyLongKeyThatNoOneShouldAlignWith: "also a string",
	}
	fmt.Println(myVar)
}

Full failed step details: https://travis-ci.org/cloudflare/cloudflare-go/jobs/397558038#L498

@ianlancetaylor ianlancetaylor changed the title gofmt: Struct literal alignment differing between 1.10 and 1.11beta1 go/format: Struct literal alignment differing between 1.10 and 1.11beta1 Jun 27, 2018
@ianlancetaylor
Copy link
Contributor

CC @griesemer to check that this is an intentional change.

@ianlancetaylor ianlancetaylor added this to the Go1.11 milestone Jun 27, 2018
@ianlancetaylor ianlancetaylor added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 27, 2018
@griesemer
Copy link
Contributor

Yes, this was an intentional change (commit 542ea5a). See that change for justification.

@jacobbednarz
Copy link
Author

Awesome stuff! Thanks a bunch for a speedy response and great commit overview of the change!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants