Creating golang binary with the .interp section set to /lib64/

Hello, I would like to build binary that have a “standard” interp section to be able to deploy them in a docker container / AWS Lambda instance.

For now, I have tried static build (but I use MySQL so my binary fails to run) and I have also tried to build inside an FHS user env.

This is what look like an ldd output of my binary: (0x00007ffd13929000) => /nix/store/pnd2kl27sag76h23wa5kl95a76n3k9i3-glibc-2.27/lib/ (0x00007f186ef88000) => /nix/store/pnd2kl27sag76h23wa5kl95a76n3k9i3-glibc-2.27/lib/ (0x00007f186edd2000)
	/nix/store/pnd2kl27sag76h23wa5kl95a76n3k9i3-glibc-2.27/lib/ => /nix/store/pnd2kl27sag76h23wa5kl95a76n3k9i3-glibc-2.27/lib64/ (0x00007f186efab000)

I would like to replace /nix/store/pnd2kl27sag76h23wa5kl95a76n3k9i3-glibc-2.27/lib/ to /lib/ and I can’t use patchelf as it doesn’t work on Go binaries.

My goal is to make a Go binary that can be executed on other Linux distribution.

Thanks in advance

OK, I have found a solution. You just need to pass this flag to Go:
-ldflags “-I=/lib64/”