Hacker News new | past | comments | ask | show | jobs | submit login

Go users seem to value a single static executable quite highly, a single portable executable would be even better in the same direction.



It should be noted Go hasn't spit out static executables by default for at least 5 years now (if not longer), and if you want static executables from Go it requires several arcane incantations (not unlike getting a static binary from GCC).

Basically every Go executable is dynamically linked against libc these days unless the builder goes seriously out of their way to get a static binary.


I'm not sure that's true.

    $ go version
    go version go1.18.3 linux/amd64
    
    $ cat static.go 
    package main
    
    import "fmt"
    
    func main() {
     fmt.Println("static")
    }
    
    $ go build static.go 
    
    $ file static
    static: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, Go BuildID=TSoFKMWZzy5G6qyFvxx5/dwEbvdQns9f-iffR-lbW/iTmqy3UF8tbT-GGwVH61/lUZUt7_XebTifpVvE_52, not stripped
    
    $ ldd static
     not a dynamic executable
But it might not be the case for all systems. And some things, like using CGO or performing DNS lookups, will necessitate dynamic linking.


Mostly because many of them weren't around when building static executables was the only thing our compilers could spit out.


As a Go user who values statically linked executables I can definitely say I was around when this was the only thing our compilers could spit out.

The reason I value it is because it makes deployment so much easier. I've re-lived DLL Hell so many times on so many systems by now that I'll happily take the memory/filesystem/pactching pain to have something I can deploy and know it will run on the system I deploy it to any day of the week.


There is a big difference between valuing it, and acting as if it was a wonder that Go brought into the world never achieved before.

Which is how most in the community act like.

There is also a lesson on why dynamic linking is used, and why in its absence one needs to resort to IPC.


The way go uses system API is completely unportable - and largely unsupported.


Not just Go users. Nearly all products be it desktop GUI applications that self-update or backend servers I've ever developed are like this. Saves me a lot on deployments.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: