Go list

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 mainimport (    "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 ...

Get Hands-On High Performance with Go now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.