doukang8949 2012-05-07 22:59
浏览 74
已采纳

go-从ubuntu ppa安装说明

I've installed golang-stable using the Go Language ppa for Ubuntu.

The Official Installation Instructions seem to ignore this option, and don't mention it at all.

My question is: does anyone know if anything else is needed after doing the sudo apt-get for this package? In particular, do I have to manually set any environment variables?

I'm asking because I've been able to "go get" Go-SDL, but when I try to execute its test I get the following error:

$ ./test
panic: No such environment variable: GOPATH

This kind of confuses me. Shouldn't that variable be initialized already? Especially given that I have been able to compile and install a library.

  • 写回答

1条回答 默认 最新

  • dongyao5843 2012-05-08 12:43
    关注

    The go command that you installed in /usr/lib/go/bin/ internally contains a default path that is used if the environment variable GOPATH is missing. In case of the Ubuntu package this default path points to /usr/lib/go. Thus the installation directory for Go-SDL is somewhere in /usr/lib/go/src. Installing Go-SDL in this way requires root priviledges.

    I recommend you setup GOPATH as described in http://golang.org/doc/code.html and reinstall Go-SDL. For example:

    # Uninstall Go-SDL from /usr/lib/go
    sudo go clean -i github.com/0xe2-0x9a-0x9b/Go-SDL/...
    
    # Setup GOPATH
    mkdir -p $HOME/go/src
    export GOPATH=$HOME/go
    
    # Install Go-SDL into $GOPATH
    go get -v github.com/0xe2-0x9a-0x9b/Go-SDL/...
    

    The test from github.com/0xe2-0x9a-0x9b/Go-SDL needs to know GOPATH to find some resource files (based on How to access resource files after the 'go' tool installed the executable?).

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

报告相同问题?

悬赏问题

  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
  • ¥15 钢筋实图交点识别,机器视觉代码
  • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
  • ¥50 400g qsfp 光模块iphy方案
  • ¥15 两块ADC0804用proteus仿真时,出现异常
  • ¥15 关于风控系统,如何去选择
  • ¥15 这款软件是什么?需要能满足我的需求
  • ¥15 SpringSecurityOauth2登陆前后request不一致