1

Im trying to install a Go package but having the following error.

Here is my GOPATH

p@p-ubuntu:~/ba/docker-lvm-plugin$ echo $GOPATH
/usr/bin/go

Package install

p@p-ubuntu:~/ba/docker-lvm-plugin$ go get github.com/Sirupsen/logrus
    package github.com/Sirupsen/logrus: mkdir /usr/bin/go: not a directory
user1050619
  • 19,822
  • 85
  • 237
  • 413

3 Answers3

9

Your GOPATH is wrong. It should not be the path to the go binary, it should be the path to the root of your go project directory, which should contain src, pkg, and bin subdirectories. See what should be the values of GOPATH and GOROOT?

Adrian
  • 42,911
  • 6
  • 107
  • 99
0

please change the GOBIN to available path, for example $GOPATH/bin, or $GOROOT/bin

you can see GOBIN with go env

clevertension
  • 6,929
  • 3
  • 28
  • 33
-1

This worked for me in Ubuntu:

Run in the terminal -

$ go env

Find what are the GOPATH and GOROOT paths mentioned in the output given by the above command. Open settings.json in VsCode, To open settings in VsCode- use Ctrl+Shift+P and search for

Preferences: Open Settings (JSON)

After that set the following values

"go.gopath": "<paste GOPATH path found from the above terminal command>",
"go.goroot": "<paste GOROOT path found from the above terminal command>"
Satya
  • 1,569
  • 8
  • 13