How can I track down what is causing `go build` to take a long time?

Issue

Running it with -v does not really tell me what the problem is. It takes about 20s before printing even a single line.

Running it under strace outputs a lot of noise, and strace does not run on Mac OS.

Removing dependencies to see if they are the problem would be a ridiculous amount of work.

Solution

You can use the -x flag to show all commands being executed:

https://godocs.io/cmd/go#hdr-Compile_packages_and_dependencies

Answered By – user17894590

Answer Checked By – Willingham (GoLangFix Volunteer)

Leave a Reply

Your email address will not be published.