I am trying to write a script to process some code in a GOPATH
.
The code may be nested multiple directories deep.
I'll be running my script in an environment where GOPATH
doesn't exist.
What's a simple way in shell to find the GOPATH
from a nested directory inside the GOPATH
?
It works if I do something like this
GOAPTH=$(dirname $(dirname $(dirname $(dirname $(pwd)))))
or
GOPATH=$(cd ../../../../; pwd)
But it requires me to have to know how many levels I am nested.