Open matthewhughes934 opened 10 months ago
Given the following file (file.go):
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
*/
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:
--max-len
$ 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/ https://github.com/dave/dst/issues/69 (but sharing here for visibility). Since golines bails early if there's nothing to format https://github.com/segmentio/golines/blob/d7d11e6ae11721865229b1d55b8862c8bd4ca719/shortener.go#L114 in that case we don't call dst.{Parse/Printf} and hence the issue isn't triggered.
github.com/dave/dst/
dst.{Parse/Printf}
There's a fix for the issue upstream (https://github.com/dave/dst/commit/5fa8d6ebe49a6b04afa15ee8f982d210f8a00b80) 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.
go get github.com/dave/dst@5fa8d6ebe49a6b04afa15ee8f982d210f8a00b80
EDIT: upstream has created a new tag, here's a PR to include it https://github.com/segmentio/golines/pull/111
Given the following file (
file.go
):Then running
golines
with a length that ensure we do some formatting removes the newline between the closing*/
and thepackage declaration
:If
--max-len
is not given,golines
won't actually try and format anything and the the newline is preserved:This appears to be related to an upstream issue in
github.com/dave/dst/
https://github.com/dave/dst/issues/69 (but sharing here for visibility). Sincegolines
bails early if there's nothing to format https://github.com/segmentio/golines/blob/d7d11e6ae11721865229b1d55b8862c8bd4ca719/shortener.go#L114 in that case we don't calldst.{Parse/Printf}
and hence the issue isn't triggered.There's a fix for the issue upstream (https://github.com/dave/dst/commit/5fa8d6ebe49a6b04afa15ee8f982d210f8a00b80) 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 https://github.com/segmentio/golines/pull/111