CmdID

CmdID / Commands

gofmt

Format Go source code. tldr-pages

On several platforms

Opens CmdID with your command. It is read in your browser and sent nowhere.

Several platforms

from tldr-pages, CC BY 4.0

Format a file and display the result to the console

gofmt path/to/source.goIdentify

Format a file, overwriting the original file in-place

gofmt -w path/to/source.goIdentify

Format a file, and then simplify the code, overwriting the original file

gofmt -s -w path/to/source.goIdentify

Display diffs instead of rewriting files

gofmt -d path/to/source.goIdentify

List files that would be changed by gofmt

gofmt -l path/to/directoryIdentify

Apply a rewrite rule to the source before reformatting (e.g. replace nil checks with isNil calls)

gofmt -r 'x == nil -> isNil(x)' path/to/source.goIdentify

Report all errors, including multiple ones per line

gofmt -e path/to/source.goIdentify