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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?