Using VSC: Unable to import error library

王林
Release: 2024-02-09 09:06:29
forward
646 people have browsed it

使用 VSC:无法导入错误库

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.

Question content

I opened a go file in vsc, and I saw that some basic go libraries have been imported:

import (
    "flag"
    "fmt"
    "time"
Copy after login

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?

Workaround

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!

source:stackoverflow.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!