douhuilin1152 2014-01-30 17:22
浏览 42
已采纳

软件包下载失败,“未设置GOPATH”。为什么?

OS: Ubuntu 12.04

Go version reporting: 1.1.1

Action:

I have configured the .profile to contain the following lines:

export GOPATH="$HOME/workspace"

export PATH=$PATH:$GOPATH/bin

I have ensured that they are set in the go configuration by running "go env". However when I try to run the command, the screen reports as shown in the image below:

enter image description here

Possible constraining issues:

1) The box originally had Go v1.0 on it and I upgraded it to go version1.1.1, not sure that should mean anything...but if there is some twin configuration madness at work that may explain the fact it's not working despite the path being set.

2) I had the export commands in the .profile file but I see some threads indicate to put it in .bashrc, trying in either still gives the same problem.

Do I need to uninstall go 1.0 ? I just assumed version 1.1.1 would over ride it but that could be wrong. Ideally I wanted to uninstall go entirely and then install version 1.1.2 but I couldn't find anything at golang.org on uninstalling assuming that does solve the problem.

Thanks in advance for any assistance.

  • 写回答

1条回答 默认 最新

  • drtzb06222 2014-01-30 20:38
    关注

    As the commenter above stated, you should not use sudo with go get. When you do, you have the root user's environment (which doesn't have your GOPATH) and any files or directories it creates won't be editable by your user. In the past, the go get command would not warn about not having a $GOPATH and so it was easier to get tripped up by this.

    To fix your permissions, run the following command to change ownership back to your user:

    sudo chown -R "$USER:" "$GOPATH"
    

    You should only ever need to run a plain go get because you can (and should) set your $GOPATH to be a directory you can control. Be sure to read the How To Write Go Code and in particular its discusson on GOPATH.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥188 寻找能做王者评分提取的
  • ¥15 matlab用simulink求解一个二阶微分方程,要求截图
  • ¥30 乘子法解约束最优化问题的matlab代码文件,最好有matlab代码文件
  • ¥15 写论文,需要数据支撑
  • ¥15 identifier of an instance of 类 was altered from xx to xx错误
  • ¥100 反编译微信小游戏求指导
  • ¥15 docker模式webrtc-streamer 无法播放公网rtsp
  • ¥15 学不会递归,理解不了汉诺塔参数变化
  • ¥15 基于图神经网络的COVID-19药物筛选研究
  • ¥30 软件自定义无线电该怎样使用