With the introduction of -linkshared
one can write a go program that uses shared libraries and end up with much smaller compiled files.
By default the final executable file looks for the shared libraries under GOROOT
path.
What I am trying to achieve is to have all our libraries installed under our own custom directory (say /usr/local/ourprogram/lib) and then having our executable to look there for the libraries.
One solution is to have a simple shell script alongside our executable and assign the GOLANG
environment variable and then call our program. Somethine like this:
#!/bin/sh
GOROOT=/usr/local/ourprogram/lib; ourprogram
But what I wish to achieve is to have that path somehow inside our program in order to avoid having that extra bash script.
Is this achievable through a compilation flag or maybe a comment directive?