Install golang on Ubuntu 14.04 LTS
senjougahara · · 13837 次点击 · · 开始浏览1. Install golang on Ubuntu 14.04 LTS
a)~$ sudo apt-get install golang success
b)~$ sudo add-apt-repository ppa:gophers/go
~$ sudo apt-get update
~$ sudo apt-get install golang-stable fail
c) complie from source code fail to download source code, fuk GFW
2. Version of golang
~$ go version go version go1.2.1 linux/amd64
3. Default env of golang
~$ go env GOARCH="amd64" GOBIN="" GOCHAR="6" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="" GORACE="" GOROOT="/usr/lib/go" GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64" TERM="dumb" CC="gcc" GOGCCFLAGS="-g -O2 -fPIC -m64 -pthread" CXX="g++" CGO_ENABLED="1"
Someone said that:
"You don't need to set GOROOT, really."
http://dave.cheney.net/2013/06/14/you-dont-need-to-set-goroot-really
In another go doc page:
"The GOPATH environment variable specifies the location of your workspace. It is likely the only environment variable you'll need to set when developing Go code."
Here is the discuss about GOROOT and GOPATH.
http://stackoverflow.com/questions/7970390/what-should-be-the-values-of-gopath-and-goroot
4. Set Vim for golang
Here is the most common way.
a) ~$ cp -r $GOROOT/misc/vim/* ~/.vim/ // I can't find '/misc/vim/*'. It may not exist now.
b) Attend follow commands in ~/.vimrc. If ~/.vimrc doesn't exist, create it.
filetype plugin indent on
syntax on // I feel very confused about how to add golang syntax highlighting for vim.
c) install Gocode
Here is my way.
a) Install Vundle
git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
If ~/.vim/bundle/vundle doesn't exist, create it.
b) Add following commands to the head of ~/.vimrc.
set nocompatible " be iMproved filetype off " required! set rtp+=~/.vim/bundle/vundle/ call vundle#rc() " let Vundle manage Vundle " required! Bundle 'gmarik/vundle' filetype plugin indent on syntax on
c) Install vim-go
~$ sudo apt-get install mercurial ~$ cd ~/.vim/bundle ~$ git clone https://github.com/fatih/vim-go.git
Add this line to ~/.vimrc.
Plugin 'fatih/vim-go'
Execute :PluginInstall in Vim. // Fail to connect google service. Fuk GFW!
d) Install Gocode
~$ go get -u github.com/nsf/gocode
~$ cd $GOPATH/src/github.com/nsf/gocode/vim
~$ ./update.bash
~$ gocode set propose-builtins true
~$ gocode set lib-path "$GOPATH/pkg/linux_amd64"
May be enough for beginners.
Reference
fatih/vim-go
https://github.com/fatih/vim-go
nsf/gocode
https://github.com/nsf/gocode
set vim for golang (Chinese)
http://ju.outofmemory.cn/entry/49172
Let's have fun!
有疑问加站长微信联系(非本文作者)
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
关注微信- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码` - 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传
收入到我管理的专栏 新建专栏
1. Install golang on Ubuntu 14.04 LTS
a)~$ sudo apt-get install golang success
b)~$ sudo add-apt-repository ppa:gophers/go
~$ sudo apt-get update
~$ sudo apt-get install golang-stable fail
c) complie from source code fail to download source code, fuk GFW
2. Version of golang
~$ go version go version go1.2.1 linux/amd64
3. Default env of golang
~$ go env GOARCH="amd64" GOBIN="" GOCHAR="6" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="" GORACE="" GOROOT="/usr/lib/go" GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64" TERM="dumb" CC="gcc" GOGCCFLAGS="-g -O2 -fPIC -m64 -pthread" CXX="g++" CGO_ENABLED="1"
Someone said that:
"You don't need to set GOROOT, really."
http://dave.cheney.net/2013/06/14/you-dont-need-to-set-goroot-really
In another go doc page:
"The GOPATH environment variable specifies the location of your workspace. It is likely the only environment variable you'll need to set when developing Go code."
Here is the discuss about GOROOT and GOPATH.
http://stackoverflow.com/questions/7970390/what-should-be-the-values-of-gopath-and-goroot
4. Set Vim for golang
Here is the most common way.
a) ~$ cp -r $GOROOT/misc/vim/* ~/.vim/ // I can't find '/misc/vim/*'. It may not exist now.
b) Attend follow commands in ~/.vimrc. If ~/.vimrc doesn't exist, create it.
filetype plugin indent on
syntax on // I feel very confused about how to add golang syntax highlighting for vim.
c) install Gocode
Here is my way.
a) Install Vundle
git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
If ~/.vim/bundle/vundle doesn't exist, create it.
b) Add following commands to the head of ~/.vimrc.
set nocompatible " be iMproved filetype off " required! set rtp+=~/.vim/bundle/vundle/ call vundle#rc() " let Vundle manage Vundle " required! Bundle 'gmarik/vundle' filetype plugin indent on syntax on
c) Install vim-go
~$ sudo apt-get install mercurial ~$ cd ~/.vim/bundle ~$ git clone https://github.com/fatih/vim-go.git
Add this line to ~/.vimrc.
Plugin 'fatih/vim-go'
Execute :PluginInstall in Vim. // Fail to connect google service. Fuk GFW!
d) Install Gocode
~$ go get -u github.com/nsf/gocode
~$ cd $GOPATH/src/github.com/nsf/gocode/vim
~$ ./update.bash
~$ gocode set propose-builtins true
~$ gocode set lib-path "$GOPATH/pkg/linux_amd64"
May be enough for beginners.
Reference
fatih/vim-go
https://github.com/fatih/vim-go
nsf/gocode
https://github.com/nsf/gocode
set vim for golang (Chinese)
http://ju.outofmemory.cn/entry/49172
Let's have fun!