How to use a relative path for LDFLAGS in golang

You currently can't. The directory changes between the time the command is built, and linking. For now you either need to link to an absolute path, or use the CGO_LDFLAGS environment variable.

There was a commit just after go1.4 which added a ${SRCDIR} variable which is replaced by the absolute path to the directory containing the source file at build time. https://github.com/golang/go/issues/7891. This will be in go1.5, and you can easily use it now by building Go from source.