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

前端 未结 7 893
清酒与你
清酒与你 2021-01-31 08:35

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 ver

7条回答
  •  再見小時候
    2021-01-31 09:05

    Using go1.6,

    Simply run go build -i.

    It will compile all the dependencies and store them at $GOPATH/pkg/*/* as .a files.

    Later when you run go run main.go, everything is much faster.

    What s really great is that if you use vendored dependencies (IE: a vendor folder in your project), deps are built appropriately within $GOPATH/pkg/**/yourproject/vendor/**

    So you don t have to go get install/get/whatever and have a mix of vendor / global dependencies.

    I suspect you got to re-build .a files after deps update (glide update or smthg like this), but i did not test that yet.

提交回复
热议问题