Home > Back-end >  Goland can't auto import "fmt"?
Goland can't auto import "fmt"?

Time:11-29

Goland (version 2021.2, on Linux) can't auto import "fmt", when add a line of code that use fmt's functions.
I need to add import "fmt" by hand.
But seems it doesn't have problem with other built-in go packages.

It that a bug, or a special design ?

BTW, the similar issue occur for 3rd-party package "github.com/stretchr/testify/assert", the auto import will hint several options to import assert, but the above one is always not in the list in my case, had to import by hand.

CodePudding user response:

There is Global Println() function and also fmt.Println() function()

If you writh Println and press ctl space only then IDE will set autocomplete Println().

/// add

enter image description here

Also you have to check this. Is there any exclucde from import and completion?

If doesn't exist, then my last advise is doing invalidate caches/ restart

enter image description here

CodePudding user response:

you should set your GOPATH and GOROOOT in your configuration.

  • Related