News for hackers. Stuff that matters.
Re:Go automatically downloads a newer toolchain if needed by anotherhue on Tuesday August 20, 2024 @08:16AM (#41299336)
Best worst thing about nixos is that none of these terrifying tricks work because the binaries can never find libc.
Re:Go automatically downloads a newer toolchain if needed by evomassiny on Tuesday August 20, 2024 @09:03AM (#41299700)
I thought go binaries were purely static, aren't they ?
Re:Go automatically downloads a newer toolchain if needed by cpuguy83 on Tuesday August 20, 2024 @09:16AM (#41299781)
If 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.
Re:Go automatically downloads a newer toolchain if needed by kokada on Tuesday August 20, 2024 @09:23AM (#41299828)
Author 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.

Re:Go automatically downloads a newer toolchain if needed by cpuguy83 on Tuesday August 20, 2024 @09:17AM (#41299789)
... Or do some other flags to statically link to cgo.
Re:Go automatically downloads a newer toolchain if needed by kokada on Tuesday August 20, 2024 @09:12AM (#41299765)
Author here and NixOS user.

This works even in NixOS, because `go` toolchain is statically compiled.