go list performs the action of listing named packages and modules, as well as displaying important build information about files, imports, and dependencies. The invocation stanza for go list is usage: go list [-f format] [-json] [-m] [list flags] [build flags] [packages].
Having access to the data structures that are the main pieces of the build process is powerful. We can use go list to find out a lot about the programs that we are building. For example, take the following simple program, which prints a message and computes a square root for the end user:
package main
import (
"fmt"
"math"
)
func main() {
fmt.Println("Hello Gophers")
fmt.Println(math.Sqrt(64))
}
If we want to find out about all the dependencies that we have for our particular project, we can invoke the go list -f '{{.Deps}}' command.
The result will be a...