Set LD_LIBRARY_PATH while executing go test

697 views
Skip to first unread message

laksh...@gmail.com

unread,
Jun 16, 2017, 1:47:02 AM6/16/17
to golang-nuts
Hello,

Is there a way to set the LD_LIBRARY_PATH while executing go test command? 

My version is "go version go1.5.1 linux/amd64"

Thanks

Uli Kunitz

unread,
Jun 16, 2017, 7:12:15 AM6/16/17
to golang-nuts
Bash supports:
```
LD_LIBRARY_PATH=/foo/bar go test 
```
Is that what you want?

messju mohr

unread,
Jun 16, 2017, 8:38:24 AM6/16/17
to Uli Kunitz, golang-nuts
... and a shell agnostic way would be:

$ env LD_LIBRARY_PATH=/foo/bar go test

(see the man page of env(1))

regards

laksh...@gmail.com

unread,
Jun 19, 2017, 12:36:24 AM6/19/17
to golang-nuts, uli.k...@gmail.com
Hello,

Is there any flags which can be used? other than explicitly setting the env variable? 

Uli Kunitz

unread,
Jun 19, 2017, 1:47:03 AM6/19/17
to golang-nuts, uli.k...@gmail.com
There is no documented flag for go test to set the LD_LIBRARY_PATH. From my point of view there is also no need for it.

Michael Hudson-Doyle

unread,
Jun 19, 2017, 5:55:53 PM6/19/17
to laksh...@gmail.com, golang-nuts
No. Why do you want to?

You can set the rpath of the generated executable with something like "go test -ldflags='-r $foo'" or "go test -ldflags=-extldflags=-Wl,-rpath=$foo" which might be another way to solve your problem. But I'm just guessing really.

Cheers,
mwh

David Collier-Brown

unread,
Jun 19, 2017, 9:31:34 PM6/19/17
to golang-nuts
I used to write tons of interposers, what is it you are trying to do in Go?
Reply all
Reply to author
Forward
0 new messages