-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
go.tools/cmd/goimports: order of dot imports differs from gofmt #7866
Labels
Comments
http://play.golang.org/p/cvG0QUhg0H Check Imports then click Format. Now uncheck it and click Format again. |
The problem is in imports.go: https://code.google.com/p/go/source/browse/imports/imports.go?repo=tools&r=1911e4f0ca34#241 var impLine = regexp.MustCompile(`^\s+(?:\w+\s+)?"(.+)"`) That regex fails to match dot imports (it works fine for _ and renamed imports, since \w captures that, but not dot). It can be fixed by changing the regex to: var impLine = regexp.MustCompile(`^\s+(?:[\w\.]+\s+)?"(.+)"`) In my testing, that fixes this issue. Being regex, it may introduce other issues (and it's unfortunate to need to resort to regex to make Go source modifications), so I'll let someone else figure out if this is acceptable. I could make a CL for it, but I already have one in flight, so I'll wait until that moves forward, or after 1.3 is out. |
This issue was fixed by https://golang.org/cl/99400043. Can someone close it please? |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: