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

line break between /* … */ comments and package statement removed #110

Open
matthewhughes934 opened this issue Oct 14, 2023 · 0 comments

Comments

@matthewhughes934
Copy link

matthewhughes934 commented Oct 14, 2023

Given the following file (file.go):

/*
this is a description of the package
*/
package lib

func SomeLongFuncNameToBreakLineLength() {
}

Then running golines with a length that ensure we do some formatting removes the newline between the closing */ and the package declaration:

$ golines --max-len=20 file.go 
/*
this is a description of the package
*/package lib

func SomeLongFuncNameToBreakLineLength() {
}

If --max-len is not given, golines won't actually try and format anything and the the newline is preserved:

$ golines --max-len=20 file.go 
/*
this is a description of the package
*/
package lib

func SomeLongFuncNameToBreakLineLength() {
}

This appears to be related to an upstream issue in github.com/dave/dst/ dave/dst#69 (but sharing here for visibility). Since golines bails early if there's nothing to format

if linesToShorten == 0 {
in that case we don't call dst.{Parse/Printf} and hence the issue isn't triggered.

There's a fix for the issue upstream (dave/dst@5fa8d6e) but there's not been a new tag to include it. Testing that with go get github.com/dave/dst@5fa8d6ebe49a6b04afa15ee8f982d210f8a00b80 and I see the issue is resolved.

EDIT: upstream has created a new tag, here's a PR to include it #111

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

No branches or pull requests

1 participant