2025-03-14 21:59:59 -06:00
# go fmt
> Format Go source files, printing the changed filenames.
2026-07-08 16:22:34 -06:00
> Note: `./...` is a Go package pattern understood by Go tooling. It matches the current package and all packages recursively under the current directory.
2025-03-14 21:59:59 -06:00
> More information: <https://pkg.go.dev/cmd/go#hdr-Gofmt__reformat__package_sources>.
- Format Go source files in the current directory:
`go fmt`
- Format a specific Go package in your import path (`$GOPATH/src` ):
`go fmt {{path/to/package}}`
- Format the package in the current directory and all subdirectories (note the `...` ):
`go fmt {{./...}}`
- Print what format commands would've been run, without modifying anything:
`go fmt -n`
- Print which format commands are run as they are run:
`go fmt -x`