13 ms·
I thought go binaries were purely static, aren't they ?
by evomassiny 2y ago
I thought go binaries were purely static, aren't they ?
- cpuguy83 2y agoIf you import net or os then you'll automatically link to libc unless you disable cgo or set the "netgo" and "osusergo" build tag respectively.
- cpuguy83 2y ago... Or do some other flags to statically link to cgo.
- kokada 2y agoAuthor here. You are confusing the `go` toolchain and the binaries generated with Go toolchain. The `go` toolchain itself is compiled statically, this is why this works without issues even in NixOS. Binaries built with the toolchain may or may not be linked against libc depending if you enable or disable CGO. But this is not related to the toolchain, that will work regardless since the toolchain itself is statically compiled. Edit: or in other words, the `go` toolchain is built with CGO disabled.