Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm 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 Go installation to the Go SDK list, I get the following error

The selected directory is not a valid home for Go Sdk

I have tried adding the following directories as the 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 get this working? I've commented on the various issues in the bugtracker, however the maintainer claimed that this was fixed 10 months ago.

Failing that, does anyone know what this plugin is actually looking for that would make a directory look like the SDK directory?

like image 644
Thomas Avatar asked Oct 01 '13 05:10

Thomas


5 Answers

I came this issue when config goroot path in goland idea.

enter image description here I solve it as follows,

Go the GO SDK path and find zversion.go, then append the file with

const TheVersion = `go1.17.2`

. You need to change the version according to you case.

In my case the sversion.go path is located at D:\Programs\Go\src\runtime\internal\sys\zversion.go.

Save the file, and restart the goland ide, then config the GOROOT (File -> setting -> Go -> GOROOT -> + -> local...), select you Go root path and save it.

enter image description here

like image 101
LF00 Avatar answered Nov 17 '22 16:11

LF00


It turns out that google-go-lang-idea-plugin requires a slightly different folder structure than the default apt install produces. To fix it:

# 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
like image 37
Thomas Avatar answered Nov 17 '22 17:11

Thomas


addon: got the same problem on go1.18.4, just need to add this line of code in ${GOROOT}/src/runtime/internal/sys/zversion.go

const TheVersion = `go1.18`
like image 3
Flybywind Avatar answered Nov 17 '22 15:11

Flybywind


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

I had installed the IntelliJ Go Plugin a while ago and installed GO 1.5 a while back, and it all worked fine. Now i checked and suddenly, I'm sure I didn't remove it, GO 1.5 was gone from my system. But who knows, I haven't worked with go for a bit, so I might have removed it.

Anyway, after a bit of debugging, the following steps helped me:

  1. Install the most current Go version (currently for me 1.6.3). Follow the instructions on https://golang.org/doc/install
  2. Update the Plugin for Go in IntelliJ !!!
  3. Set the SDK in IntelliJ for the project:File -> Project Structure -> Project -> under Project SDK add a New SDK and navigate to your go installation.
  4. Click Apply and then Ok
like image 1
flamingo Avatar answered Nov 17 '22 16:11

flamingo


Step 1: Open cmd

Step 2: Run below command => go env

Step 3: Find GOROOT and according this GOROOT path select directory for Go Sdk.

like image 2
Ashikur Rahman Rashid Avatar answered Nov 17 '22 17:11

Ashikur Rahman Rashid