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

8.8k views Asked by At

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.

2

There are 2 answers

1
guettli On

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.
2
jjkim On

Try

golangci-lint run --fix

and you can go from there!