I'm trying to create a pure statically linked binary to run in a minimal Docker container. Prior to Go 1.5, I was building them like this:
go build -a -tags netgo -installsuffix netgo myfile.go
I understand that C has been stripped out of the Go compiler in version 1.5. Is it still necessary to build with -tags
and -installsuffix
?
https://golang.org/doc/go1.5#net
The DNS resolver in the net package has almost always used cgo to access the system interface. A change in Go 1.5 means that on most Unix systems DNS resolution will no longer require cgo, which simplifies execution on those platforms. Now, if the system's networking configuration permits, the native Go resolver will suffice. The important effect of this change is that each DNS resolution occupies a goroutine rather than a thread, so a program with multiple outstanding DNS requests will consume fewer operating system resources.
The decision of how to run the resolver applies at run time, not build time. The netgo build tag that has been used to enforce the use of the Go resolver is no longer necessary, although it still works. A new netcgo build tag forces the use of the cgo resolver at build time. To force cgo resolution at run time set GODEBUG=netdns=cgo in the environment. More debug options are documented here.
This change applies to Unix systems only. Windows, Mac OS X, and Plan 9 systems behave as before.
So no.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With