goimports

Command goimports updates your Go import lines, adding missing ones and removing unreferenced ones.

Version

c1def519f03ddf76f16b3e444ee1095d73afa01b

Runtime

Go Versions

Supported Languages

Go

Official Documentation

https://godoc.org/golang.org/x/tools/cmd/goimports

YAML Configuration

goimports:

  • input:

    Patterns to include in execution and reports.

  • ignore:

    Patterns to exclude from execution and reports.

  • auto-fix:

    true/false

    Specifying true implies -w option.

    Note: As of now, goimports does not keep CRLF line endings and all EOL characters are converted to LF in files where the auto-fix is applied. We will solve this problem, but for the time being, please don't enable the auto-fix feature if you need to keep CRLF line endings.

  • options:

    Below is the list of options that are supported:

    -local string
            put imports beginning with this string after 3rd-party packages; comma-separated list
  • experimental:

    • incremental:

      N/A

      Note: The incremental analysis is not supported for goimports. This is because Inspecode always attempts to resolve external dependencies (by go get by default) and the results on unchanged files can be affected by the dependencies. See Resolving Dependencies about how the dependencies are resolved.

YAML Examples

  • With default options:

    inspecode:
      goimports: default
  • With enabling auto-fixing and default options:

    inspecode:
      goimports: auto-fix
  • With custom machine:

    inspecode:
      goimports:
        machine:
          cpu: 1.5 # 1.5 CPU, 5760 MiB RAM

Resolving Dependencies

goimports may report false-positives if the dependencies are not found locally, so Inspecode resolves the dependencies in the same manner as go test. See the go test page for the details.

results matching ""

    No results matching ""