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.

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

报告相同问题?

悬赏问题

  • ¥15 我这个代码哪里有问题 acm 平台上显示错误 90%,我自己运行好像没什么问题
  • ¥50 C#编程中使用printDocument类实现文字排版打印问题
  • ¥15 找会编程的帅哥美女 可以用MATLAB里面的simulink编程,用Keil5编也可以。
  • ¥15 已知隐函数其中一个变量τ的具体值,求另一个变量
  • ¥15 r语言Hurst指数
  • ¥15 Acrn IVSHMEM doorbell问题
  • ¥15 yolov5中的val测试集训练时数量变小问题
  • ¥15 MPLS/VPN实验中MPLS的配置问题
  • ¥15 materialstudio氢键计算问题
  • ¥15 echarts图表制作