{"record":{"id":"cc39af34a7470aa7","repo":"urfave/cli","slug":"goimports-needed","errorCode":null,"errorMessage":"goimports needed","messagePattern":"goimports needed","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/build.go","lineNumber":647,"sourceCode":"\t)\n}\n\nfunc LintActionFunc(ctx context.Context, cmd *cli.Command) error {\n\ttopDir := cmd.String(\"top-dir\")\n\tif err := os.Chdir(topDir); err != nil {\n\t\treturn err\n\t}\n\n\tout, err := sh(ctx, filepath.Join(topDir, \".local/bin/goimports\"), \"-l\", \".\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif strings.TrimSpace(out) != \"\" {\n\t\tfmt.Fprintln(cmd.ErrWriter, \"# ---> goimports -l is non-empty:\")\n\t\tfmt.Fprintln(cmd.ErrWriter, out)\n\n\t\treturn errors.New(\"goimports needed\")\n\t}\n\n\treturn nil\n}\n\nfunc V3Diff(ctx context.Context, cmd *cli.Command) error {\n\tif err := os.Chdir(cmd.String(\"top-dir\")); err != nil {\n\t\treturn err\n\t}\n\n\terr := runCmd(\n\t\tctx,\n\t\t\"diff\",\n\t\t\"--ignore-all-space\",\n\t\t\"--minimal\",\n\t\t\"--color=\"+func() string {\n\t\t\tif cmd.Bool(\"color\") {\n\t\t\t\treturn \"always\"","sourceCodeStart":629,"sourceCodeEnd":665,"githubUrl":"https://github.com/urfave/cli/blob/1a4deb4f5a35ee12706602698dc0527d44c14b19/scripts/build.go#L629-L665","documentation":"LintActionFunc runs goimports -l over the codebase and fails the build with this error if the output is non-empty, meaning at least one file is not formatted according to goimports. It is an intentional lint gate, not a runtime fault: some source files need import fixes or formatting.","triggerScenarios":"Committing code with unsorted/mis-formatted imports or gofmt divergence, then running the lint action (e.g. ./build lint). Any file listed by goimports -l triggers it.","commonSituations":"Editing files without running goimports, merge conflicts resolved with stray formatting, adding imports manually in the wrong group, or a different local goimports version than CI.","solutions":["Run goimports -w . (or gofmt -s -w .) on the repo to auto-fix all listed files, then re-run lint.","Configure your editor to run goimports on save so files are formatted before commit.","If CI disagrees with local results, align the Go/goimports toolchain version with CI."],"exampleFix":"// before (CI step)\n./build lint  # fails: goimports needed\n// after\nadd a pre-commit/CI step: goimports -l -w . && ./build lint","handlingStrategy":"fallback","validationCode":"out, err := exec.Command(\"goimports\", \"-l\", \".\").Output()\nif err == nil && len(out) == 0 {\n\t// safe to proceed\n}","typeGuard":null,"tryCatchPattern":"if err := lint(ctx, cmd); err != nil {\n\tif strings.Contains(err.Error(), \"goimports needed\") {\n\t\tif fix := exec.Command(\"goimports\", \"-w\", \".\"); fix.Run() == nil {\n\t\t\treturn lint(ctx, cmd) // retry after auto-format\n\t\t}\n\t}\n\treturn err\n}","preventionTips":["Run goimports -w on save in your editor.","Add a pre-commit hook running goimports -l and blocking non-formatted files.","Keep your local Go/goimports versions aligned with CI."],"tags":["go","linting","code-formatting","ci"],"backgroundTag":"lint-format-check-failed","analyzedSha":"1a4deb4f5a35ee12706602698dc0527d44c14b19","analyzedAt":"2026-08-31T18:42:09.451Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}