Last Updated: February 25, 2016
·
2.852K
· aniljava

intellij $GOPATH $GOROOT fix

idea intellij go plugin does not accept custom GOPATH, this .bashrc function is to synchronize the GOPATH with GOROOT.

Requires GOPATH and GOROOT pre defined. Replace linux_amd64 with your archetecture.

goup to copy to GOROOT, and godown to remove them (required for go install on GOPATH).

function goup {
ls -1 $GOPATH/pkg/linux_amd64/ | xargs -I {} ln -s $GOPATH/pkg/linux_amd64/{} $GOROOT/pkg/linux_amd64/{}
  ls -1 $GOPATH/src/ | xargs -I {} ln -s $GOPATH/src/{}/ $GOROOT/src/pkg/{}
}
function godown {
  ls -1 $GOPATH/src/ | xargs -I {} rm --f $GOROOT/src/pkg/{}
  ls -1 $GOPATH/src/ | xargs -I {} rm --f $GOROOT/pkg/linux_amd64/{}
}

1 Response
Add your response

other solution:
idea -> Project Structure -> SDKs -> Go SDK ... ->
Classpath and Sourcepath add $GOPATH src and pkg dir

over 1 year ago ·