"The selected directory is not a valid home for Go Sdk."

I am using IntelliJ Idea and the google-go-lang-idea plugin from:

https://github.com/mtoader/google-go-lang-idea-plugin/issues/173

When I try to add my APT provided by Go to the Go SDK list, I get the following error

The selected directory is not a valid home for Go Sdk

I tried adding the following directories as Go SDK root

  • /usr/share/go/
  • /usr/share/src/
  • /usr/lib/go/
  • /usr/lib/go/src/
  • /usr/lib/go/pkg/
  • /usr/lib/go/pkg/linux_amd64

Does anyone know how to do this? I commented on various issues in bugtracker, however the maintainer claimed that this was fixed 10 months ago.

Otherwise, does anyone know that this plugin is really looking for the directory to look like an SDK directory?

+7
intellij-idea go google-go-idea-plugin
source share
3 answers

It turns out that google-go-lang-idea-plugin requires a slightly different folder structure than the standard apt installation creates. To fix this:

 # mkdir /usr/lib/go/bin # ln -s /usr/bin/go /usr/lib/go/bin/go # ln -s /usr/bin/godoc /usr/lib/go/bin/godoc # ln -s /usr/bin/gofmt /usr/lib/go/bin/gofmt 
+1
source share

You seem to have chosen GOPATH , but the tool wants GOROOT ! Look at this test that you fail:

https://github.com/mtoader/google-go-lang-idea-plugin/blob/master/src/ro/redeul/google/go/sdk/GoSdkUtil.java#L84

I can only see linux_amd64 only under your popup, which tells me GOPATH .

In general, the current trend is to install packages / tools (especially when they are so young as GO), like non-root users and in your home directory, and configure $PATH and $GOPATH in your environment instead of installing in on a global scale. This will make updating and changing versions easier. I would recommend putting in your ~/usr/local/go and your GOPATH in ~/gopath . Then point IntelliJ to ~/usr/local/go

+1
source share

So, I had this exact problem on IntelliJ 2016.1.3 with Go 1.5.

I recently installed the IntelliJ Go plugin and installed GO 1.5 some time ago, and it all worked fine. Now I checked and suddenly, I'm sure I did not delete it, GO 1.5 left my system. But who knows, I did not work to go a bit, so I could remove it.

In any case, after a little debugging, the following steps helped me:

  • Install the latest version of Go (currently 1.6.3 for me). Follow the instructions https://golang.org/doc/install
  • Update the plugin for Go IntelliJ !!!
  • Install the SDK in IntelliJ for the project: File -> Project Structure -> Project -> under Project SDK add a New SDK and navigate to your go installation .
  • Click Apply and then Ok
0
source share

All Articles