go-fmt

Format Go source files.

TLDR

Format Go source files in the current directory

$ go fmt
copy

Format a specific Go package in your import path ($GOPATH/src)

$ go fmt [path/to/package]
copy

Format the package in the current directory and all subdirectories (note the ...)

$ go fmt [./...]
copy

Print what format commands would've been run, without modifying anything

$ go fmt -n
copy

Print which format commands are run as they are run

$ go fmt -x
copy

SYNOPSIS

go fmt [ā€†-nā€†] [ā€†-xā€†] [ packages ]

DESCRIPTION

Fmt runs the command 'gofmt -l -w' on the packages named by the import paths. It prints the names of the files that are modified.

For more about gofmt, see 'godoc gofmt'.

For more about specifying packages, see go-packages(7).

To run gofmt with specific options, run gofmt itself.

OPTIONS

-n

The -n flag causes tool to print the command that would be executed but not execute it.

-x

The -x flag causes clean to print remove commands as it executes them.

SEE ALSO

go-doc(1), go-fix(1), go-vet(1).

AUTHOR

This manual page was written by Michael Stapelberg <stapelberg@debian.org>, for the Debian project (and may be used by others).

Copied to clipboard
linuxmousepad