用mkdir去安装错误:权限被拒绝

Even after ensuring proper read / write access to your GOPATH folder you can still receive permission errors.

I tried sudo chmod -R sourcefolder/ and sudo chown -R username sourcefolder/ without any luck.

I needed to unset my GOBIN variable in order to fix this issue. GOBIN doesn't need to be set anymore by default. More details here: https://github.com/golang/go/wiki/InstallTroubleshooting

You can check whether it's set with echo $GOBIN. You can unset it via unset GOBIN. If it's set in your bash file then it's different per operating system:

macOS: nano ~/.bash_profile Linux: nano ~/.bash_aliases

Use CTRL+W on either platform to search and type in GOBIN.