Two useful Go tools

The Go distribution comes with a plethora of tools that can make your life as a programmer easier. The two most useful of them are gofmt and godoc.

Note that go tool itself can also invoke various tools: you can see a list of them by executing go tool.

The gofmt utility formats Go programs in a given way, which is really important when different people are going to work with the same code for a big project. You can find more information about gofmt at

The following is a poorly formatted version of the hw.go program that is hard to read and understand:

$ cat unglyHW.go
package main
// This is a demonstrative comment!
        func main() {
  fmt.Println("Hello World!")

Processing the ...

Get Go Systems Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.