How to disable Golang unused import error

前端 未结 8 2086
我寻月下人不归
我寻月下人不归 2020-12-05 03:30

By default, Go treats unused import as error, forcing you to delete the import. I want to know if there exists some hope to change to this behavior, e.g. reducing it to warn

8条回答
  •  忘掉有多难
    2020-12-05 04:21

    Use goimports. It's basically a fork of gofmt, written by Brad Fitzpatrick and now included in the go tools packages. You can configure your editor to run it whenever you save a file. You'll never have to worry about this problem again.

提交回复
热议问题