btw, default autotools compiles seem to make the static library... you get a .a, .la (which just points at the .a as its binary) and .so in maybe several versions - at least with libsecp256k1 it was
and so i was able to do this:
mleku@iox:~/src/realy.lol/cmd/realy$ ls -lash|grep realy
23M -rwxrwxr-x 1 mleku mleku 23M Nov 10 20:16 realy
4.0K -rw-rw-r-- 1 mleku mleku 414 Oct 20 22:57 realy.service
mleku@iox:~/src/realy.lol/cmd/realy$ ldd realy
not a dynamic executable
and you see, that only added 3mb to the size of the binary and i can distribute that and it will work on any system with glib2 on amd64 architecture
this is how i did it:
mleku@iox:~/src/realy.lol$ go build --ldflags '-extldflags "-static"' -o ~/bin/realy ./cmd/realy/.
# realy.lol/cmd/realy
/usr/bin/ld: /tmp/go-link-1787515793/000021.o: in function `mygetgrgid_r':
/_/GOROOT/src/os/user/cgo_lookup_cgo.go:45:(.text+0x44): warning: Using 'getgrgid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /tmp/go-link-1787515793/000021.o: in function `mygetgrnam_r':
/_/GOROOT/src/os/user/cgo_lookup_cgo.go:54:(.text+0xe5): warning: Using 'getgrnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /tmp/go-link-1787515793/000022.o: in function `mygetgrouplist':
/_/GOROOT/src/os/user/getgrouplist_unix.go:15:(.text+0x22): warning: Using 'getgrouplist' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /tmp/go-link-1787515793/000004.o: in function `_cgo_04fbb8f65a5f_C2func_getaddrinfo':
/tmp/go-build/cgo-gcc-prolog:60:(.text+0x37): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /tmp/go-link-1787515793/000021.o: in function `mygetpwnam_r':
/_/GOROOT/src/os/user/cgo_lookup_cgo.go:36:(.text+0x18a): warning: Using 'getpwnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /tmp/go-link-1787515793/000021.o: in function `mygetpwuid_r':
/_/GOROOT/src/os/user/cgo_lookup_cgo.go:27:(.text+0x249): warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
being that glibc has been at version 2 for like 20 years that's probably ok... and even if they do bump to a 3 there probably will be glib.so.2 libraries installed by default for a long time