snippetbashTip
go fmt — Format Go source files, printing the changed filenames. More information: <https://pkg.go.dev/cmd/go
Viewed 0 times
thecommandformatfilessourcecligo fmtprinting
Problem
How to use the
go fmt command: Format Go source files, printing the changed filenames. More information: <https://pkg.go.dev/cmd/go#hdr-Gofmt__reformat__package_sources>.Solution
go fmt — Format Go source files, printing the changed filenames. More information: <https://pkg.go.dev/cmd/go#hdr-Gofmt__reformat__package_sources>.Format Go source files in the current directory:
go fmtFormat 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 -nPrint which format commands are run as they are run:
go fmt -xCode Snippets
Format Go source files in the current directory
go fmtFormat 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 -nPrint which format commands are run as they are run
go fmt -xContext
tldr-pages: common/go fmt
Revisions (0)
No revisions yet.