GOPATH设置不正确,无法下载

Initially the error happens when I want to install with go

sudo go get github.com/njasm/gosoundcloud
package github.com/njasm/gosoundcloud: cannot download, $GOPATH not set. For more details see: go help gopath

But when I look for the GOPATH

echo $GOPATH
home/maker/go

I can also build scripts, what is wrong?

Don't use sudo.

Your $GOPATH is pointing to your local use account. So a guess is that you have $GOPATH set in your .profile or .bashrc file, meaning it is local to your user.

Go is meant to run within your user space, with no sudo for development.

so...

go get github.com/njasm/gosoundcloud

If you installed Go with sudo apt-get install Go, that's fine. Just make sure your $GOPATH is set properly for your user, and run the command abve without sudo.

Now, if you are trying to install a binary (is gosoundcloud a binary?), then first build it under your account:

go install github.com/njasm/gosoundcloud

This puts the binary into $GOPATH/bin. Then just cp it:

sudo cp /home/maker/go/bin/{binary name} /usr/bin

Or alike...