1. How to Fix File is not gofumpt
-ed (gofumpt) error
gofumpt is a stricter version of gofmt. The lint tool finds more errors and reports. One such error is that File is not gofumpt-ed. The solution to the problem is as follows:
Please install gofumpt
The easiest solution is to run gofumpt on the troubled files.
gofumpt -w <fileame>
2. File is not gci
-ed with -local github.com/golangci/golangci-lint
GCI, a tool that control golang package import order and make it always deterministic.
It handles empty lines more smartly than goimport
does.
- install
go get github.com/daixiang0/gci
- run
gci -w -local github.com/daixiang0/gci main.go
3. File is not goimports
-ed with -local github.com/golangci/golangci-lint
方案 1 手动执行格式化。
go get golang.org/x/tools/cmd/goimports
goimports -e -d -local github.com/golangci/golangci-lint internal/net/http/handler.go
goimports -w internal/net/http/handler.go
方案 2 配置 goland 的代码格式化规则。参考 Running ‘goimports’ on save in GoLand
相关阅读