gofmt
Tool for formatting Go source code. More information: <https://golang.org/cmd/gofmt/>.
Install
- All systems
-
curl cmd.cat/gofmt.sh
- Debian
-
apt-get install golang-1.12-go
- Ubuntu
-
apt-get install golang-1.12-go
- Arch Linux
-
pacman -S go-pie
- Kali Linux
-
apt-get install golang-1.11-go
- CentOS
-
yum install gcc-go
- Fedora
-
dnf install gcc-go
- Windows (WSL2)
-
sudo apt-get update
sudo apt-get install golang-1.12-go
- Raspbian
-
apt-get install golang-1.6-go
- Dockerfile
- dockerfile.run/gofmt
Tool for formatting Go source code. More information: <https://golang.org/cmd/gofmt/>.
-
Format a file and display the result to the console:
gofmt source.go
-
Format a file, overwriting the original file in-place:
gofmt -w source.go
-
Format a file, and then simplify the code, overwriting the original file:
gofmt -s -w source.go
-
Print all (including spurious) errors:
gofmt -e source.go
© tl;dr; authors and contributors