Error “cannot download, $GOPATH not set.”

后端 未结 6 1479
南旧
南旧 2021-02-02 08:41

Setup:

Have a look at my configuration:

$ echo $GOPATH && ls -r $GOPATH
/home/cyrus/.go
src  pkg  bin

$ echo $GOROOT &&         


        
6条回答
  •  耶瑟儿~
    2021-02-02 09:07

    My $GOROOT directory was created with owner: root and group: wheel instead having me as the owner and admin as the group. I'll guess that I used sudo when I shouldn't have (or some tool did it for me). As such go get could not write the packages to $GOROOT and hence the $GOPATH not set and permission denied errors.

    By using chown and chgrp on my $GOROOT (with -R to get subfolders) 'go get...' worked. In my case VS Code was now able to install the Go components I was after.

提交回复
热议问题