php Xiaobian Xigua introduces you to a common problem, that is, when using VSC (Visual Studio Code), you encounter the situation of being unable to import the wrong library. This kind of problem often occurs during the development process and brings some trouble to developers. This article will explain how to solve this problem and help you with your coding work smoothly.
I opened a go file in vsc, and I saw that some basic go libraries have been imported:
import ( "flag" "fmt" "time"
But when I try to add "error" vsc doesn't allow it and just removes it from the import.
I also understand that error is one of the basic go libraries, like fmt etc.
Then why doesn't it work for me?
Go does not allow unused imports to remain in the source code.
VSCode uses gofmt
by default to format Go source code on save, and goimports
as an alternative if available. In addition to all the features of gofmt
, a highlight of goimports
is that it can validate and organize your imports, which is very helpful for reducing compiler errors.
The above is the detailed content of Using VSC: Unable to import error library. For more information, please follow other related articles on the PHP Chinese website!