Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"go build" became very slow after installing a new version of Go

Tags:

go

After upgrading from Go 1.2.1 to 1.3 (Windows 7 64 bit) "go build" execution time has increased from around 4 to over 45 seconds. There were no other changes except the go version update. Switching off the virus scanner seems to have no effect. Any clues?

like image 450
Nikolai Koudelia Avatar asked Jun 21 '14 12:06

Nikolai Koudelia


People also ask

How long is go build?

After upgrading from Go 1.2. 1 to 1.3 (Windows 7 64 bit) "go build" execution time has increased from around 4 to over 45 seconds. There were no other changes except the go version update.

Does go build get dependencies?

Additionally, other commands, such as go build or go test, will add new dependencies automatically based on the stipulated requirements. For example, as earlier illustrated, they can do this to satisfy import requirements, including upgrading go. mod file and installing the new dependencies.

What is go build command?

Go The Go Command Go Build Println("Hello, World!") } build creates an executable program, in this case: main or main.exe . You can then run this file to see the output Hello, World! . You can also copy it to a similar system that doesn't have Go installed, make it executable, and run it there.

How do I run a go file after build?

The same way you'd run any other executable. ./program or program.exe . After you run go build main.go , there will be a new file with the name of the folder containing your main.go file. That is the executable. If the directory containing the main.go file is named toto , on unix you have to type ./toto to execute it.


2 Answers

You probably have dependencies that are being recompiled each time. Try go install -a mypackage to rebuild all dependencies.

Removing $GOPATH/pkg also helps to ensure you don't have old object files around.

Building with the -x flag will show you if the toolchain is finding incompatible versions.

like image 100
JimB Avatar answered Oct 08 '22 03:10

JimB


I have the exact same problem, running this command solves it:

go get -u -v github.com/mattn/go-sqlite3

Another tip: http://kokizzu.blogspot.co.id/2016/06/solution-for-golang-slow-compile.html

like image 23
Kokizzu Avatar answered Oct 08 '22 03:10

Kokizzu