douting1871 2016-05-07 00:19
浏览 216
已采纳

在Ubuntu上设置GOPATH-仍然出现错误

I have set following path on my ~/.bashrc file

export GOPATH=/usr/lib/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

But when i installed ATOM IDE and i tried to install go-plus package, it tired to download something at the end and i got the error that

package github.com/nsf/gocode: cannot download, $GOPATH not set. For more details see: go help gopath

What I am doing wrong ? Here is my ubunt information as well.

Distributor ID: Ubuntu
Description:    Ubuntu 15.10
Release:    15.10
Codename:   wily

P.S

I have already tried setting my

export GOPATH=/home/<username/go
export PATH=$PATH:$GOPATH/bin
  • 写回答

2条回答 默认 最新

  • dtfo55908 2016-05-07 00:33
    关注

    Okay guys, I figured out the problem.

    https://github.com/joefitzgerald/go-plus/issues/386

    here it has been discussed. I will just copy it from that

    Linux folks, particularly those running Ubuntu. I believe I have reproduced your issues and I think they have to do with where you are setting your GOPATH and PATH.

    • ~/.profile: If you set them here, $GOPATH will be set in Atom when you launch Atom for the first time from the launcher in the toolbar

    • ~/.bashrc If you set them here, $GOPATH will be set in Atom when you launch Atom for the first time from the terminal Thus, to ensure GOPATH and PATH are set correctly regardless of how you launch Atom, you should put the following (or similar) in both ~/.profile and ~/.bashrc:

    export GOPATH=$HOME/work
    
    export PATH=$GOPATH/bin:/usr/local/go/bin:$PATH
    

    Obviously the above doesn't apply exactly if bash isn't your default shell, but I trust that if you're a user of a different shell, you can grok what I am saying above and apply the same principles to your particular environment.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵