-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: provide a flag for the local import path prefix #12420
Comments
CC @bradfitz |
Seems fine I guess. I suppose to tell your editor to pass the argument you might need to make a wrapper program which added the arg, depending on your editor. |
I just sent https://golang.org/cl/25145. If matchPattern were handy, I would have made this a pattern like 'example.com/...'. But a simple prefix gets the job done (for me anyway). The plumbing was a little gross. I'm all ears for a cleaner approach. |
This allows the caller to indicate they want certain import paths to sort into another group after 3rd-party imports when added by goimports. For example, running 'goimports -local example.com/' might produce import ( "database/sql" "io" "strconv" "golang.org/x/net/context" "example.com/foo/bar" "example.com/foo/baz" ) Updates golang/go#12420 Change-Id: If6d88599f6cca2f102313bce95ba6ac46ffec1fe
CL https://golang.org/cl/25145 mentions this issue. |
This allows the caller to indicate they want certain import paths to sort into another group after 3rd-party imports when added by goimports. For example, running 'goimports -local example.com/' might produce import ( "database/sql" "io" "strconv" "golang.org/x/net/context" "example.com/foo/bar" "example.com/foo/baz" ) Updates golang/go#12420 Change-Id: If6d88599f6cca2f102313bce95ba6ac46ffec1fe
My company has tried to adopt a convention placing import paths into three groups: standard library followed by third-party packages followed by local packages. For example
We'd like to be able to add a flag to our goimports-on-save hook, like
to tell goimports to put any paths beginning with "mycompany.com/" into our third group. I think that would end up as group value 3 in the goimports source: stdlib=0, 3rd party=1, appengine=2, then local=3.
If this sounds reasonable, I can write a patch.
The text was updated successfully, but these errors were encountered: