How To Install Gofmt On Debian, Ubuntu, Arch, Kali, CentOS, Fedora And Raspbian?

How To Install Gofmt On Debian, Ubuntu, Arch, Kali, CentOS, Fedora And Raspbian?

gofmt

Tool for formatting Go source code.

Install gofmt

  • Debian apt-get install golang-1.12-go Click to copy
  • Ubuntu apt-get install golang-1.12-go Click to copy
  • Arch Linux pacman -S go-pie Click to copy
  • Kali Linux apt-get install golang-1.11-go Click to copy
  • CentOS yum install gcc-go Click to copy
  • Fedora dnf install gcc-go Click to copy
  • Raspbian apt-get install golang-1.6-go Click to copy

Tool for formatting Go source code.

How to use gofmt?

Below are few example commands for gofmt that you can use in the terminal.

Format a file and display the result to the console:
gofmt source.goClick to copy
Format a file, overwriting the original file in-place:
gofmt -w source.goClick to copy
Format a file, and then simplify the code, overwriting the original file:
gofmt -s -w source.goClick to copy
Print all (including spurious) errors:
gofmt -e source.goClick to copy
Installation of latest gofmt command is available for Debian, Ubuntu, Arch, Kali, CentOS, Fedora and Raspbian. You can copy the command for your OS from above and paste it into your terminal. Once you run the command it will download the 2026 latest package from the repository and install it in your computer/server.