Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Imports order and preferences #2425

maoueh started this conversation in General
Discussion options

In certain circumstances where a Go package can be imported from different fully qualified name like assert or require, I notice different behavior between auto-import and Ctrl+Space suggestion.

The specific case I face the most often is that I write a unit test, I add require or assert statement like assert.Equal(...) then when I save, the "wrong" import is added (I say wrong just because it's not the one I wanted).

If I instead write assert.Equal(...) then place my cursor right after assert (between t and .) then I do Ctrl+Space to see suggestions, then the first listed is the one I would like to actually use. It could be a coincidence and they are simply alphabetically sorted.

So I was wondering what is the way auto-import decides which import to pick to resolve a particular package? Is there anyway currently to "tweak" this behavior a bit maybe provide a list of my preferred resolution?

You must be logged in to vote

Replies: 0 comments

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

AltStyle によって変換されたページ (->オリジナル) /