sudo apt-get install bison ed gawk gcc libc6-dev make
安装Mercurial(类似pip,gem):
Mercurial是一个版本管理系统,可以直接在终端输入"hg"来检查是否已经安装该软件
sudo apt-get install python-setuptools python-dev build-essential mercurial
获取Go语言源码包:
进入保存Go语言源码的路径
hg clone -r release https://go.googlecode.com/hg/ go
配置Go语言环境变量:
sudo vim /etc/profile:
export GOROOT=/opt/Go/go
export GORACH=amd64
export GOOS=linux
export GOPATH=/home/works/go #该目录至少包含三个文件夹bin,pkg,src
export PATH=$GOROOT/bin:$PATH
编译Go源码:
cd $GOROOT/src
./all.bash
go
下载Sublime Text:
http://www.sublimetext.com/
tar -jxvf Sublime Text 2.0.1 x64.tar.bz2 sublime.tar.bz2
cd sublime_text
#将Sublime Text添加到Launcher中:
cd /usr/share/applications
ls -a
sudo gedit sublime-text.desktop
###
[Desktop Entry]
Encoding=UTF-8
Version=2.0
Type=Application
Terminal=false
Icon=/opt/Go/sublime_text/Icon/48x48/sublime_text.png
Name=Sublime Text
Comment=Sublime text 2
Icon[zh_CN]=/opt/Go/sublime_text/Icon/48x48/sublime_text.png
Name[zh_CN]=Sublime Text
Comment[zh_CN]=Sublime text 2
Exec=/opt/Go/sublime_text/sublime_text %F
Categories=Development;
###
安装gosublime:
安装Sublime Text的Package Control功能,在打开Sublime Text软件后,按下快捷键 Ctrl+`
###
import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print 'Please restart Sublime Text to finish installation'
###
按住Ctrl+Shift+p会弹出一个会话框,在其中输入"install"后
输入"gosublime",选中并回车,然后输入"go build",选中并回车
Hello World:
在终端输入以下指令:nano $GOPATH/src/hello.go
go run $GOPATH/src/hello.go
参考:
http://my.oschina.net/Obahua/blog/110767
http://www.cnblogs.com/yourihua/archive/2012/06/04/2529333.html