Meaning of "File is not `gci`-ed with –skip-generated -s standard,default (gci)"

huangapple go评论130阅读模式
英文:

Meaning of "File is not `gci`-ed with --skip-generated -s standard,default (gci)"

问题

我得到了这个错误信息:

main.go:24: File is not `gci`-ed with --skip-generated -s standard,default (gci)
import (

这是什么意思?

背景:我是Go的新手,代码检查不是我设置的。我承认我不知道是哪个代码检查工具导致了这个警告。

英文:

I get this error message:

main.go:24: File is not `gci`-ed with --skip-generated -s standard,default (gci)
import (

What does this mean?

Background: I am new to Go, and the linting was not set up by me. I confess that I don't know the actual linter which creates this warning.

答案1

得分: 7

尝试使用以下命令进行修复:

golangci-lint run --fix

然后你可以从那里开始!

英文:

Try

golangci-lint run --fix

and you can go from there!

答案2

得分: 6

gci 是一个控制 Golang 包导入顺序并始终保持确定性的工具。

在使用 golangci-lint 对代码进行 lint 检查时,gci linter 所需的更改不会直接应用。因此,需要手动应用这些更改。可以通过以下方式获取 gci

go install github.com/daixiang0/gci@latest

使用以下命令扫描代码并直接写入所需的更改:

gci write --skip-generated -s standard,default .
  • --skip-generated 跳过生成的文件
  • -s standard,default 定义导入输入的处理方式。standard 是所有官方提供的 Golang 导入,default 是其他所有导入。
英文:

gci is
> a tool that controls golang package import order and makes it always deterministic.

When linting the code with golangci-lint, the changes required by the gci linter are not directly applied. One then has to manually apply them. For this get gci with

 go install github.com/daixiang0/gci@latest

scan it and directly write required changes with

gci write --skip-generated -s standard,default .
  • --skip-generated skips generated files
  • -s standard,default defines how import inputs are processed. standard are all official Golang provided imports, default are all other ones.

huangapple
  • 本文由 发表于 2023年1月19日 23:46:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/75174808.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定