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/gofmt: gofmt -r should preserve multiline formatting #18677

Open
rogpeppe opened this issue Jan 16, 2017 · 2 comments
Open

cmd/gofmt: gofmt -r should preserve multiline formatting #18677

rogpeppe opened this issue Jan 16, 2017 · 2 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@rogpeppe
Copy link
Contributor

rogpeppe commented Jan 16, 2017

go version devel +ac05542 Wed Jan 11 01:39:54 2017 +0000 linux/amd64

gofmt -r does not work well when rewriting multi-line expressions.

Given this code:

package x

func f() {
	Foo{
		X: 99,
		Y: "hello",
	}
}

running:

gofmt -r 'Foo{X: a, Y: b} -> Foo{
    X: a,
    Y: []byte(b),
}'

results in:

package x

func f() {
	Foo{X: 99, Y: []byte(

		"hello")}

}

In general, if the replacement expression contains multiple lines, their
placement is ignored.

@rakyll
Copy link
Contributor

rakyll commented Jan 17, 2017

/cc @griesemer

@griesemer
Copy link
Contributor

Unfortunate. Problem acknowledged but not high on the list of issues.

@griesemer griesemer self-assigned this Jan 17, 2017
@griesemer griesemer added this to the Unplanned milestone Jan 17, 2017
@seankhliao seankhliao added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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