Skip to content
This repository has been archived by the owner on Jun 14, 2018. It is now read-only.

gofmt produces empty new line #48

Open
xh3b4sd opened this issue Oct 21, 2016 · 0 comments
Open

gofmt produces empty new line #48

xh3b4sd opened this issue Oct 21, 2016 · 0 comments

Comments

@xh3b4sd
Copy link

xh3b4sd commented Oct 21, 2016

I like the package very much. It is only that there is this one very annoying detail that all go files that are formatted using this package end up having an empty line at the end of the file. This should be fixed IMO. As you can see in the screenshot I made from the developer console, the property r.stdout holds the formatted source code having the trailing newline attached. The beginning of the formatted source code string is correct, the end is not.

"package main

import "fmt"

func main() {
    fmt.Printf("%#vn", "foo")
}
"

This is how it should look like. Note the difference of the end of the code.

"package main

import "fmt"

func main() {
    fmt.Printf("%#vn", "foo")
}"

screen shot 2016-10-21 at 16 42 28

Also note that I am using goimports, but gofmt is doing the same. In fact, it is not the go tools that produce this, but the OS command execution and stdout capturing itself. I think a simple check for a newline at the end and removing it in case it is there should be good enough. This is the result now.

screen shot 2016-10-21 at 16 58 07

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant