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

前端 未结 7 888
清酒与你
清酒与你 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:12

    After Go 1.10, you'd just need to type go build. You'd not need to type: go build -i.

    From the draft Go 1.10 document, here.


    Build & Install

    The go build command now detects out-of-date packages purely based on the content of source files, specified build flags, and metadata stored in the compiled packages. Modification times are no longer consulted or relevant. The old advice to add -a to force a rebuild in cases where the modification times were misleading for one reason or another (for example, changes in build flags) is no longer necessary: builds now always detect when packages must be rebuilt. (If you observe otherwise, please file a bug.)

    ...

    The go build command now maintains a cache of recently built packages, separate from the installed packages in $GOROOT/pkg or $GOPATH/pkg. The effect of the cache should be to speed builds that do not explicitly install packages or when switching between different copies of source code (for example, when changing back and forth between different branches in a version control system). The old advice to add the -i flag for speed, as in go build -i or go test -i, is no longer necessary: builds run just as fast without -i. For more details, see go help cache.

    0 讨论(0)
提交回复
热议问题