Forrest logo
back to the go tool

go-fmt:tldr:81b42

go-fmt: Print what format commands would've been run, without modifying anything.
$ go fmt -n
try on your machine

The go fmt command is used to format Go source code. It follows the official Go formatting guidelines and automatically reformats the code to adhere to those style rules.

The -n flag in go fmt -n is used to perform a "sanity check" or "dry run" of the formatting process. When this flag is provided, the go fmt command will display a list of files that would be modified if the formatting was actually applied, without actually modifying them.

This is useful to verify which files are not already formatted correctly and would be modified if the command is run without the -n flag. It allows you to preview the changes that will be made before actually applying them.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the go tool