I'm trying to understand how to build static executable in Go and I need to link it against external library, in my case ORACLE, but the use case is generic. I do the following:
go build -x --ldflags '-s -w -extldflags "-static -L$ORACLE_HOME/lib -lclntsh"'
The compilation phase is fine, but linking part fails to find external lib(s):
/path/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/path/x86_64-redhat-linux-gnu/bin/ld: cannot find -lclntsh
I'm skipping here full path for better readability. The gcc linker can't see passed -L path and library (in my case -L$ORACLE_HOME/lib -lclntsh).
So, the question is how for any generic case to pass external library path and libs to linker using go build command.