> Aren't go programs statically linked?
Not by default. You have to set CGO_ENABLED=0 to statically link libc.
Not by default. You have to set CGO_ENABLED=0 to statically link libc.
Now if it said "Go code is usually/by default statically linked", then yes.
$ cat foo.go
package main
import (
"fmt"
)
func main() {
fmt.Println("Hello")
}
$ go build foo.go
$ file foo
foo: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, not stripped
compared to: $ cat bar.go
package main
import (
"os/user"
"fmt"
)
func main() {
u, err := user.Current()
fmt.Println(u, err)
}
$ go build bar.go
$ file bar
bar: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, not stripped CGO_ENABLED=0 go build
even when using os/user or net/