{"record":{"id":"3e7ad0e8012fdc75","repo":"golangci/golangci-lint","slug":"build-walk-options-w","errorCode":null,"errorMessage":"build walk options: %w","messagePattern":"build walk options: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/commands/fmt.go","lineNumber":107,"sourceCode":"\n\treturn nil\n}\n\nfunc (c *fmtCommand) preRunE(_ *cobra.Command, _ []string) error {\n\tif c.cfg.GetConfigDir() != \"\" && c.cfg.Version != \"2\" {\n\t\treturn fmt.Errorf(\"invalid version of the configuration: %q\", c.cfg.Version)\n\t}\n\n\tmetaFormatter, err := goformatters.NewMetaFormatter(c.log, &c.cfg.Formatters, &c.cfg.Run)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create meta-formatter: %w\", err)\n\t}\n\n\tmatcher := processors.NewGeneratedFileMatcher(c.cfg.Formatters.Exclusions.Generated)\n\n\topts, err := goformat.NewRunnerOptions(c.cfg, c.opts.diff, c.opts.diffColored, c.opts.stdin)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"build walk options: %w\", err)\n\t}\n\n\tc.runner = goformat.NewRunner(c.log, metaFormatter, matcher, opts)\n\n\treturn nil\n}\n\nfunc (c *fmtCommand) execute(_ *cobra.Command, args []string) error {\n\tpaths := cleanArgs(args)\n\n\tc.log.Infof(\"Formatting Go files...\")\n\n\terr := c.runner.Run(paths)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to process files: %w\", err)\n\t}\n\n\treturn nil","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/commands/fmt.go#L89-L125","documentation":"fmt's preRunE builds goformat.NewRunnerOptions from the loaded config plus diff/diffColored/stdin flags. Failure is wrapped as \"build walk options\". This constructs file-walking/processing options (paths, exclusions, output modes); invalid combinations or values make fmt unable to set up its runner.","triggerScenarios":"Running `golangci-lint fmt` with incompatible flags/options: e.g. --stdin together with paths or --diff, invalid diff coloring option, or invalid exclusions/run settings affecting the walker.","commonSituations":"Combining `fmt --stdin` with directory arguments; using --diff and --stdin simultaneously; malformed exclusion patterns in `formatters.exclusions`.","solutions":["Read the wrapped cause to see which option is invalid.","Don't mix --stdin with path arguments or --diff; use one input mode at a time.","Check --diff-colored is only used with --diff and your terminal supports it.","Validate exclusion patterns in the config's formatters.exclusions section."],"exampleFix":"// before\ngolangci-lint fmt --stdin ./...\n// after\ngolangci-lint fmt --stdin        # stdin alone\ngolangci-lint fmt ./...          # or paths alone","handlingStrategy":"validation","validationCode":"// ensure mutually exclusive flags aren't combined\nif stdin && (len(paths) > 0 || diff) {\n  return fmt.Errorf(\"--stdin cannot be combined with paths or --diff\")\n}\nif diffColored && !diff {\n  return fmt.Errorf(\"--diff-colored requires --diff\")\n}","typeGuard":null,"tryCatchPattern":"if err := fmtCmd.Run(); err != nil {\n  if strings.Contains(err.Error(), \"build walk options\") {\n    log.Fatalf(\"bad flag combination: %v\", errors.Unwrap(err))\n  }\n  return err\n}","preventionTips":["Use --stdin alone; pass paths as plain arguments otherwise.","Only use --diff-colored together with --diff.","Keep exclusion patterns in config valid globs; test them with a single file first."],"tags":["golangci-lint","formatters","cli-flags"],"backgroundTag":"invalid-cli-flag-combination","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}