gofmt

Gofmt formats Go programs.

Version

Go Versions

Runtime

Go Versions

Supported Languages

Go

Official Documentation

https://godoc.org/github.com/golang/go/src/cmd/gofmt

YAML Configuration

gofmt:

  • 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, gofmt 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.

  • config-file:

    N/A

  • machine:

    • cpu:

      Amount of CPU. The default machine has 0.25 CPU with 960 MiB RAM.

  • options:

    Below is the list of options that are supported:

    -r rule
            Apply the rewrite rule to the source before reformatting.
    -s
            Try to simplify code (after applying the rewrite rule, if any).
    

YAML Examples

  • With default options:

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

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

    inspecode:
      gofmt:
        machine:
          cpu: 1.5 # 1.5 CPU, 5760 MiB RAM
    
  • With custom options:

    inspecode:
      gofmt:
        auto-fix: true
        options:
          -s:
          -r: 'a[b:len(a)] -> a[b:]'
    

results matching ""

    No results matching ""