码迷,mamicode.com
首页 > 其他好文 > 详细

Install golang on Ubuntu 14.04 LTS

时间:2014-06-08 18:37:28      阅读:331      评论:0      收藏:0      [点我收藏+]

标签:c   style   class   blog   code   java   

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

bubuko.com,布布扣
~$ 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"
bubuko.com,布布扣

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.

bubuko.com,布布扣
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
bubuko.com,布布扣

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!

Install golang on Ubuntu 14.04 LTS,布布扣,bubuko.com

Install golang on Ubuntu 14.04 LTS

标签:c   style   class   blog   code   java   

原文地址:http://www.cnblogs.com/senjougahara/p/3774592.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!