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
x/tools/cmd/goimports: moves comment to inappropriate line #23709
Comments
Change https://golang.org/cl/93055 mentions this issue: |
@bradfitz Can you take a look? |
I would like to start contributing to Go. Would this be a good issue to cut my teeth on? |
@lukelafountaine it looks like someone may have already sent a patch for this--see the comment about CL 93055 above. |
I'm not sure it's a problem, but this line: https://github.com/golang/tools/blob/master/go/ast/astutil/imports.go#L141 set all imported line to the same position in file, then when sorting it, the current position is tracked: https://github.com/golang/tools/blob/master/imports/sortimports.go#L106 In this example, |
Change https://golang.org/cl/121878 mentions this issue: |
cc @bradfitz I sent new CL for this issue, please take a look |
This change appears to have broken goimports in a different way putting spurious blank lines after import lines with comments. ~/go/src/github.com/ncw/rclone$ find . -name *.go | grep -v /vendor/ | xargs goimports -d diff -u ./cmd/serve/webdav/webdav.go.orig ./cmd/serve/webdav/webdav.go
--- ./cmd/serve/webdav/webdav.go.orig 2018-07-03 22:24:12.339811431 +0100
+++ ./cmd/serve/webdav/webdav.go 2018-07-03 22:24:12.339811431 +0100
@@ -16,6 +16,7 @@
"github.com/ncw/rclone/vfs/vfsflags"
"github.com/spf13/cobra"
"golang.org/x/net/context" // switch to "context" when we stop supporting go1.8
+
"golang.org/x/net/webdav"
)
diff -u ./fs/rc/rc.go.orig ./fs/rc/rc.go
--- ./fs/rc/rc.go.orig 2018-07-03 22:24:13.099814169 +0100
+++ ./fs/rc/rc.go 2018-07-03 22:24:13.099814169 +0100
@@ -12,6 +12,7 @@
"io"
"net/http"
_ "net/http/pprof" // install the pprof http handlers
+
"strings"
"github.com/ncw/rclone/cmd/serve/httplib" I don't know if that was intended but before this change goimports didn't insert that spurious blank line. |
@ncw, could you file a new bug and cc the author on it and reference this bug? |
Change https://golang.org/cl/122538 mentions this issue: |
The fix in golang/go#23709 introduced a separate bug where extra blank lines were sometimes inserted. This fixes that newly introduced bug. Fixes golang/go#26246 Change-Id: I78131cc1d01ae246922ed9e4336ebb31d1c6cfa1 Reviewed-on: https://go-review.googlesource.com/122538 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Create a file with the following contents:
Expected:
Versions tested:
go version go1.10rc1 linux/amd64
go version go1.9.3 linux/amd64
The text was updated successfully, but these errors were encountered: