go version go1.8 linux/amd64
For example,
package main
var V int
go build -buildmode=plugin -v test/main.go
lion@Lion-Laptop [ test ] $ go build -buildmode=plugin -v test/main.go
command-line-arguments
lion@Lion-Laptop [ test ] $
lion@Lion-Laptop [ test ] $ go build -buildmode=plugin -v test/main.go
runtime/internal/sys
runtime/internal/atomic
runtime
runtime/cgo
command-line-arguments
lion@Lion-Laptop [ test ] $
The same as building with -a
This is because all packages need to be rebuilt by the toolchain configured for dynamic linking, and by default go build
does not cache intermediate package builds. I believe work on cmd/go will change that, and this problem will go away.
Until then, you can use -i
when building plugins to cache intermediate package builds, so this only happens the first time:
$ go build -buildmode=plugin -i -v plugin1
runtime/internal/sys
runtime/internal/atomic
runtime
common
internal/cpu
errors
unicode/utf8
sync/atomic
unicode
internal/race
math
sync
syscall
strconv
reflect
runtime/cgo
plugin1
$ go build -buildmode=plugin -i -v plugin1
plugin1
$
Most helpful comment
This is because all packages need to be rebuilt by the toolchain configured for dynamic linking, and by default
go build
does not cache intermediate package builds. I believe work on cmd/go will change that, and this problem will go away.Until then, you can use
-i
when building plugins to cache intermediate package builds, so this only happens the first time: