Skip to Content
marmot
Commands

Build, apply every machine applicable fix (missing imports, unused imports and variables, := with no new variables, ...), and build again until no fix applies. -all adds fixes that may be incorrect, such as typo corrections.

Usage
marmot fix [packages] [flags]

Examples

marmot fix
marmot fix -code M0005 ./cmd/app
marmot fix -all

marmot fix applies the machine applicable fixes of build errors, then those of the fmt and modernize checks. After each round it type checks the changed packages and undoes the fixes of any package that no longer builds; -test also requires their tests to pass.

  • -code M0004,M0005 limits it to those build error codes.
  • -all adds fixes that may be incorrect, such as typo corrections and vet or lint suggestions.
  • -only fmt,modernize applies only those check fixes.
  • -diff prints the patches and changes nothing.
  • -upgrade go1.N raises the module's go version first.
marmot fix -diff -only modernize

Every fix carries an applicability: machine-applicable (safe to apply unseen), maybe-incorrect (likely, check it) or has-placeholders (never applied as is). Plain marmot fix applies only the first kind.

Flags

Flags take one dash or two: -release and --release are the same.

FlagMeaning
-allalso apply fixes that may be incorrect (typo corrections); check the result
-code stringonly apply fixes for these comma separated codes, for example M0004,M0005
-color stringcolor in human output: auto, always or never (NO_COLOR turns auto off) (default "auto")
-diffprint the check fixes as patches, change nothing
-jsonmachine readable output: JSON Lines on stderr (also $MARMOT_OUTPUT=json, and the default under coding agents)
-only stringapply only the fixes of these checks (fmt, modernize, vet, lint, exhaustive), not the build errors
-tags stringcomma separated build tags
-testkeep a check fix only if the tests of its package still pass
-upgrade stringraise the go version of the modules to go1.N and apply the modernizers it unlocks

Full help

marmot fix --help
Build, apply every machine applicable fix (missing imports, unused imports and variables, := with no new variables, ...), and build again until no fix applies. -all adds fixes that may be incorrect, such as typo corrections.

Usage:
  marmot fix [packages] [flags]

Examples:
marmot fix
marmot fix -code M0005 ./cmd/app
marmot fix -all

Flags:
      --all              also apply fixes that may be incorrect (typo corrections); check the result
      --code string      only apply fixes for these comma separated codes, for example M0004,M0005
      --color string     color in human output: auto, always or never (NO_COLOR turns auto off) (default "auto")
      --diff             print the check fixes as patches, change nothing
  -h, --help             help for fix
      --json             machine readable output: JSON Lines on stderr (also $MARMOT_OUTPUT=json, and the default under coding agents)
      --only string      apply only the fixes of these checks (fmt, modernize, vet, lint, exhaustive), not the build errors
      --tags string      comma separated build tags
      --test             keep a check fix only if the tests of its package still pass
      --upgrade string   raise the go version of the modules to go1.N and apply the modernizers it unlocks

On this page

Was this page helpful?

Report an issueOpen issues