1.1 Go 安裝
10余年的昆山網(wǎng)站建設(shè)經(jīng)驗(yàn),針對(duì)設(shè)計(jì)、前端、開發(fā)、售后、文案、推廣等六對(duì)一服務(wù),響應(yīng)快,48小時(shí)及時(shí)工作處理。網(wǎng)絡(luò)營銷推廣的優(yōu)勢是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動(dòng)調(diào)整昆山建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。成都創(chuàng)新互聯(lián)從事“昆山網(wǎng)站設(shè)計(jì)”,“昆山網(wǎng)站推廣”以來,每個(gè)客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。
Go的三種安裝方式
Go有多種安裝方式,你可以選擇自己喜歡的。這里我們介紹三種最常見的安裝方式:
Go源碼安裝:這是一種標(biāo)準(zhǔn)的軟件安裝方式。對(duì)于經(jīng)常使用Unix類系統(tǒng)的用戶,尤其對(duì)于開發(fā)者來說,從源碼安裝可以自己定制。
Go標(biāo)準(zhǔn)包安裝:Go提供了方便的安裝包,支持Windows、Linux、Mac等系統(tǒng)。這種方式適合快速安裝,可根據(jù)自己的系統(tǒng)位數(shù)下載好相應(yīng)的安裝包,一路next就可以輕松安裝了。**推薦這種方式**
第三方工具安裝:目前有很多方便的第三方軟件包工具,例如Ubuntu的apt-get、Mac的homebrew等。這種安裝方式適合那些熟悉相應(yīng)系統(tǒng)的用戶。
最后,如果你想在同一個(gè)系統(tǒng)中安裝多個(gè)版本的Go,你可以參考第三方工具GVM,這是目前在這方面做得最好的工具,除非你知道怎么處理。
Go源碼安裝
在Go的源代碼中,有些部分是用Plan 9 C和ATT匯編寫的,因此假如你要想從源碼安裝,就必須安裝C的編譯工具。
在Mac系統(tǒng)中,只要你安裝了Xcode,就已經(jīng)包含了相應(yīng)的編譯工具。
在類Unix系統(tǒng)中,需要安裝gcc等工具。例如Ubuntu系統(tǒng)可通過在終端中執(zhí)行sudo apt-get install gcc
libc6-dev來安裝編譯工具。
在Windows系統(tǒng)中,你需要安裝MinGW,然后通過MinGW安裝gcc,并設(shè)置相應(yīng)的環(huán)境變量。
你可以直接去官網(wǎng)下載源碼,找相應(yīng)的goVERSION.src.tar.gz的文件下載,下載之后解壓縮到$HOME目錄,執(zhí)行如下代碼:
cd go/src
./all.bash
運(yùn)行all.bash后出現(xiàn)"ALL TESTS PASSED"字樣時(shí)才算安裝成功。
上面是Unix風(fēng)格的命令,Windows下的安裝方式類似,只不過是運(yùn)行all.bat,調(diào)用的編譯器是MinGW的gcc。
如果是Mac或者Unix用戶需要設(shè)置幾個(gè)環(huán)境變量,如果想重啟之后也能生效的話把下面的命令寫到.bashrc或者.zshrc里面,
export GOPATH=$HOME/gopath
export PATH=$PATH:$HOME/go/bin:$GOPATH/bin
如果你是寫入文件的,記得執(zhí)行bash .bashrc或者bash
.zshrc使得設(shè)置立馬生效。
如果是window系統(tǒng),就需要設(shè)置環(huán)境變量,在path里面增加相應(yīng)的go所在的目錄,設(shè)置gopath變量。
當(dāng)你設(shè)置完畢之后在命令行里面輸入go,看到如下圖片即說明你已經(jīng)安裝成功
圖1.1 源碼安裝之后執(zhí)行Go命令的圖
如果出現(xiàn)Go的Usage信息,那么說明Go已經(jīng)安裝成功了;如果出現(xiàn)該命令不存在,那么可以檢查一下自己的PATH環(huán)境變中是否包含了Go的安裝目錄。
關(guān)于上面的GOPATH將在下面小節(jié)詳細(xì)講解
Go標(biāo)準(zhǔn)包安裝
Go提供了每個(gè)平臺(tái)打好包的一鍵安裝,這些包默認(rèn)會(huì)安裝到如下目錄:/usr/local/go
(Windows系統(tǒng):c:\Go),當(dāng)然你可以改變他們的安裝位置,但是改變之后你必須在你的環(huán)境變量中設(shè)置如下信息:
export GOROOT=$HOME/go
export GOPATH=$HOME/gopath
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
上面這些命令對(duì)于Mac和Unix用戶來說最好是寫入.bashrc或者.zshrc文件,對(duì)于windows用戶來說當(dāng)然是寫入環(huán)境變量。
如何判斷自己的操作系統(tǒng)是32位還是64位?
我們接下來的Go安裝需要判斷操作系統(tǒng)的位數(shù),所以這小節(jié)我們先確定自己的系統(tǒng)類型。
Windows系統(tǒng)用戶請(qǐng)按Win+R運(yùn)行cmd,輸入systeminfo后回車,稍等片刻,會(huì)出現(xiàn)一些系統(tǒng)信息。在“系統(tǒng)類型”一行中,若顯示“x64-based
PC”,即為64位系統(tǒng);若顯示“X86-based PC”,則為32位系統(tǒng)。
Mac系統(tǒng)用戶建議直接使用64位的,因?yàn)镚o所支持的Mac OS X版本已經(jīng)不支持純32位處理器了。
Linux系統(tǒng)用戶可通過在Terminal中執(zhí)行命令arch(即uname
-m)來查看系統(tǒng)信息:
64位系統(tǒng)顯示
x86_64
32位系統(tǒng)顯示
i386
Mac 安裝
訪問下載地址,32位系統(tǒng)下載go1.4.2.darwin-386-osx10.8.pkg,64位系統(tǒng)下載go1.4.2.darwin-amd64-osx10.8.pkg,雙擊下載文件,一路默認(rèn)安裝點(diǎn)擊下一步,這個(gè)時(shí)候go已經(jīng)安裝到你的系統(tǒng)中,默認(rèn)已經(jīng)在PATH中增加了相應(yīng)的~/go/bin,這個(gè)時(shí)候打開終端,輸入go
看到類似上面源碼安裝成功的圖片說明已經(jīng)安裝成功
如果出現(xiàn)go的Usage信息,那么說明go已經(jīng)安裝成功了;如果出現(xiàn)該命令不存在,那么可以檢查一下自己的PATH環(huán)境變中是否包含了go的安裝目錄。
Linux 安裝
訪問下載地址,32位系統(tǒng)下載go1.4.2.linux-386.tar.gz,64位系統(tǒng)下載go1.4.2.linux-amd64.tar.gz,
假定你想要安裝Go的目錄為 $GO_INSTALL_DIR,后面替換為相應(yīng)的目錄路徑。
解壓縮tar.gz包到安裝目錄下:tar zxvf go1.4.2.linux-amd64.tar.gz -C
$GO_INSTALL_DIR。
設(shè)置PATH,export PATH=$PATH:$GO_INSTALL_DIR/go/bin
然后執(zhí)行g(shù)o
圖1.2 Linux系統(tǒng)下安裝成功之后執(zhí)行g(shù)o顯示的信息
如果出現(xiàn)go的Usage信息,那么說明go已經(jīng)安裝成功了;如果出現(xiàn)該命令不存在,那么可以檢查一下自己的PATH環(huán)境變中是否包含了go的安裝目錄。
Windows 安裝
訪問Google Code 下載頁,32
位請(qǐng)選擇名稱中包含 windows-386 的 msi 安裝包,64 位請(qǐng)選擇名稱中包含 windows-amd64 的。下載好后運(yùn)行,不要修改默認(rèn)安裝目錄
C:\Go\,若安裝到其他位置會(huì)導(dǎo)致不能執(zhí)行自己所編寫的 Go 代碼。安裝完成后默認(rèn)會(huì)在環(huán)境變量 Path 后添加 Go 安裝目錄下的 bin 目錄
C:\Go\bin\,并添加環(huán)境變量 GOROOT,值為 Go 安裝根目錄 C:\Go\ 。
驗(yàn)證是否安裝成功
在運(yùn)行中輸入 cmd 打開命令行工具,在提示符下輸入 go,檢查是否能看到 Usage 信息。輸入
cd %GOROOT%,看是否能進(jìn)入 Go 安裝目錄。若都成功,說明安裝成功。
不能的話請(qǐng)檢查上述環(huán)境變量 Path 和 GOROOT 的值。若不存在請(qǐng)卸載后重新安裝,存在請(qǐng)重啟計(jì)算機(jī)后重試以上步驟。
第三方工具安裝
GVM
gvm是第三方開發(fā)的Go多版本管理工具,類似ruby里面的rvm工具。使用起來相當(dāng)?shù)姆奖悖惭bgvm使用如下命令:
bash (curl -s -S -L )
安裝完成后我們就可以安裝go了:
gvm install go1.4.2
gvm use go1.4.2
也可以使用下面的命令,省去每次調(diào)用gvm use的麻煩: gvm use go1.4.2 --default
執(zhí)行完上面的命令之后GOPATH、GOROOT等環(huán)境變量會(huì)自動(dòng)設(shè)置好,這樣就可以直接使用了。
apt-get
Ubuntu是目前使用最多的Linux桌面系統(tǒng),使用apt-get命令來管理軟件包,我們可以通過下面的命令來安裝Go,為了以后方便,應(yīng)該把
git mercurial 也安裝上:
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:gophers/go
sudo apt-get update
sudo apt-get install golang-stable git-core mercurial
homebrew
homebrew是Mac系統(tǒng)下面目前使用最多的管理軟件的工具,目前已支持Go,可以通過命令直接安裝Go,為了以后方便,應(yīng)該把
git mercurial 也安裝上:
brew update brew upgrade
brew install go
brew install git
brew install mercurial
首先需要下載下載go平臺(tái)安裝包
安裝程序 下載地址址h如果是您的系統(tǒng)是windows32 位系統(tǒng)請(qǐng)選擇go1.3.3.windows-386.msi即可,其他的,請(qǐng)按照自己所需版本來進(jìn)行下載,如下圖所示:
安裝以及配置環(huán)境變量
由于Windows下的的安裝包有兩種:msi和zip的;zip的是免安裝的,解壓在配置一些環(huán)境變量之后就可以使用,msi的則是安裝包版本的,安裝的時(shí)候會(huì)設(shè)置好對(duì)應(yīng)的環(huán)境變量。我的電腦是Win7 64位,因?yàn)榉奖悖拖螺d了下面的版本。下好安裝包后,安裝過程就很簡單了,一路“Next”就好了。 雖然msi會(huì)自動(dòng)配置一些環(huán)境變量,但是本人在安裝完之后還是自己配置了環(huán)境變量,所以在安裝完Go之后,我們最好還是檢查一些所有的環(huán)境變量是否正常。主要的環(huán)境變量有以下幾個(gè):
GOROOT:Go的安裝目錄
GOPATH:用于存放Go語言Package的目錄,這個(gè)目錄不能在Go的安裝目錄中
GOBIN:Go二進(jìn)制文件存放目錄,寫成%GOROOT%\bin就好
GOOS:操作系統(tǒng)
GOARCH:指定系統(tǒng)環(huán)境,i386表示x86,amd64表示x64
PATH:需要將%GOBIN%加在PATH變量的最后,方便在命令行下運(yùn)行Go
如下圖所示:
像我自己安裝的,下載完成之后解壓到任意目錄(所有目錄均不能使用中文):D:\Go;
然后是go環(huán)境變量的配置:
GOARCH:386(go安裝版本)
GOBIN:D:\Go\bin(exe執(zhí)行文件路徑)
GOOS:windows(go運(yùn)行的系統(tǒng))
GOROOT:D:\Go(go的解壓路徑)
GOPATH:E:\go\data(go的工具包路徑,隨意指定,后面會(huì)用到)
然后在path環(huán)境變量中追加:;%GOBIN%
完成之后在cmd窗口輸入:go version,如下圖所示:
1、編譯vimgdb
下載vimgdb73和vim73
mkdir -p ./tmp
cd tmp
tar zxvf ../vim-7.3.tar.gz
unzip ../vimgdb-for-vim7.3-master.zip
mv vimgdb-for-vim7.3-master vimgdb-for-vim7.3
patch -p0 vimgdb-for-vim7.3/vim73.patch
cd vim73
安裝依賴
sudo apt-get install build-essential
sudo apt-get build-dep vim-gtk
sudo apt-get install libncurses5-dev
安裝
// 這里直接執(zhí)行make的操作
make
sudo make install
安裝vimgdb runtime
cd ../vimgdb-for-vim7.3
cp vimgdb_runtime ~/.vim/bundle
打開vim
:helptags ~/.vim/bundle/vimgdb_runtime/doc " 生成doc文件
添加配置.vimrc
" vimgdb插件
run macros/gdb_mappings.vim
在vim中執(zhí)行g(shù)db時(shí),報(bào) “Unable to read from GDB pseudo tty” 的錯(cuò)誤,因?yàn)闆]有安裝 gdb ,所以安裝gdb
sudo apt-get install gdb
2、安裝vundle
set up vundle
$ git clone ~/.vim/bundle/vundle
Configure Plugins
在.vimrc文件的開頭添加下面的內(nèi)容,有些不是必須的,可以注掉
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" alternatively, pass a path where Vundle should install plugins
"let path = '~/some/path/here'
"call vundle#rc(path)
" let Vundle manage Vundle, required
Plugin 'gmarik/vundle'
" The following are examples of different formats supported.
" Keep Plugin commands between here and filetype plugin indent on.
" scripts on GitHub repos
Plugin 'tpope/vim-fugitive'
Plugin 'Lokaltog/vim-easymotion'
Plugin 'tpope/vim-rails.git'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" scripts from
Plugin 'L9'
Plugin 'FuzzyFinder'
" scripts not on GitHub
Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
Plugin ''
" ...
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" : PluginList - list configured plugins
" : PluginInstall(!) - install (update) plugins
" : PluginSearch(!) foo - search (or refresh cache first) for foo
" : PluginClean(!) - confirm (or auto-approve) removal of unused plugins
"
" see :h vundle for more details or wiki for FAQ
" NOTE: comments after Plugin commands are not allowed.
" Put your stuff after this line
Install Plugins
Launch vim and run
: PluginInstall
vim +PluginInstall +qall
3、官方vim-lang插件
Config vim file .vimrc,Add content bellow in bottom of the file
" 官方的插件
" Some Linux distributions set filetype in /etc/vimrc.
" Clear filetype flags before changing runtimepath to force Vim to
" reload them.
filetype off
filetype plugin indent off
set runtimepath+=$GOROOT/misc/vim
filetype plugin indent on
syntax on
autocmd FileType go autocmd BufWritePre Fmt
4、代碼補(bǔ)全的插件gocode
配置go的環(huán)境變量,比如我的配置,GOPATH變量是必須要配置的,PATH中必須把GOPATH的bin也添加進(jìn)去,否則沒有自動(dòng)提示,會(huì)提示找不到模式
export GOROOT=/usr/local/go
export GOPATH=/data/app/gopath
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
Set up gocode
Then you need to get the appropriate version of the gocode, for 6g/8g/5g compiler you can do this:
go get -u github.com/nsf/gocode (-u flag for "update")
Configure vim in .vimrc file
Plugin 'nsf/gocode', {'rtp': 'vim/'}
Install Plugins
Launch vim and run
: PluginInstall
vim +PluginInstall +qall
寫一個(gè)helloword程序,輸入fmt后按C-xC-o如果能看到函數(shù)的聲明展示出來,說明安裝是正確的。
4、代碼跳轉(zhuǎn)提示godef
Set up godef
go get -v code.google.com/p/rog-go/exp/cmd/godef
go install -v code.google.com/p/rog-go/exp/cmd/godef
git clone ~/.vim/bundle/vim-godef
Configure vim in .vimrc file
Bundle 'dgryski/vim-godef'
Install Plugins
Launch vim and run
: PluginInstall
vim +PluginInstall +qall
5、代碼結(jié)構(gòu)提示gotags
Set up gotags
go get -u github.com/jstemmer/gotags
Put the following configuration in your vimrc:
Bundle 'majutsushi/tagbar'
nmap :TagbarToggle
let g:tagbar_type_go = {
\ 'ctagstype' : 'go',
\ 'kinds' : [
\ 'p:package',
\ 'i:imports:1',
\ 'c:constants',
\ 'v:variables',
\ 't:types',
\ 'n:interfaces',
\ 'w:fields',
\ 'e:embedded',
\ 'm:methods',
\ 'r:constructor',
\ 'f:functions'
\ ],
\ 'sro' : '.',
\ 'kind2scope' : {
\ 't' : 'ctype',
\ 'n' : 'ntype'
\ },
\ 'scope2kind' : {
\ 'ctype' : 't',
\ 'ntype' : 'n'
\ },
\ 'ctagsbin' : 'gotags',
\ 'ctagsargs' : '-sort -silent'
\ }
命令模式下按在右邊就會(huì)顯示當(dāng)前文件下的函數(shù)名,結(jié)構(gòu)體名等等,光標(biāo)放到相應(yīng)的tag上,按回車可以快速跳到程序中的相應(yīng)位置。
再次按會(huì)關(guān)閉tag窗口。
PS:本地的.vimrc的配置
" 插件管理器 vundle
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" alternatively, pass a path where Vundle should install plugins
"let path = '~/some/path/here'
"call vundle#rc(path)
" let Vundle manage Vundle, required
Plugin 'gmarik/vundle'
" The following are examples of different formats supported.
" Keep Plugin commands between here and filetype plugin indent on.
" scripts on GitHub repos
" Plugin 'tpope/vim-fugitive'
" Plugin 'Lokaltog/vim-easymotion'
" Plugin 'tpope/vim-rails.git'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
" Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" scripts from
" Plugin 'L9'
" Plugin 'FuzzyFinder'
" scripts not on GitHub
" Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
" Plugin ''
" ...
"
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
" filetype plugin on
"
" Brief help
" : PluginList - list configured plugins
" : PluginInstall(!) - install (update) plugins
" : PluginSearch(!) foo - search (or refresh cache first) for foo
" : PluginClean(!) - confirm (or auto-approve) removal of unused plugins
"
" see :h vundle for more details or wiki for FAQ
" NOTE: comments after Plugin commands are not allowed.
" Put your stuff after this line
syntax on
" ********************************************************************
" 這里省略了其它不相關(guān)的插件
" vimgdb插件
run macros/gdb_mappings.vim
" 官方的插件
" Some Linux distributions set filetype in /etc/vimrc.
" Clear filetype flags before changing runtimepath to force Vim to
" reload them.
filetype off
filetype plugin indent off
set runtimepath+=$GOROOT/misc/vim
filetype plugin indent on
syntax on
autocmd FileType go autocmd BufWritePre buffer Fmt
" 代碼補(bǔ)全的插件
Bundle 'Blackrush/vim-gocode'
" 代碼跳轉(zhuǎn)提示
Bundle 'dgryski/vim-godef'
" 代碼結(jié)構(gòu)提示
Bundle 'majutsushi/tagbar'
nmap F8 :TagbarToggleCR
let g:tagbar_type_go = {
\ 'ctagstype' : 'go',
\ 'kinds' : [
\ 'p:package',
\ 'i:imports:1',
\ 'c:constants',
\ 'v:variables',
\ 't:types',
\ 'n:interfaces',
\ 'w:fields',
\ 'e:embedded',
\ 'm:methods',
\ 'r:constructor',
\ 'f:functions'
\ ],
\ 'sro' : '.',
\ 'kind2scope' : {
\ 't' : 'ctype',
\ 'n' : 'ntype'
\ },
\ 'scope2kind' : {
\ 'ctype' : 't',
\ 'ntype' : 'n'
\ },
\ 'ctagsbin' : 'gotags',
\ 'ctagsargs' : '-sort -silent'
\ }
具體步驟:
1、去官網(wǎng)下載go1.1.2的tarball,一般下載到tem目錄
2、打開終端cd /usr/local, tar -zxvf go1.1.2.linux-386.tar.gz
將源碼文件解壓縮到/usr/local目錄,如果解壓到其他目錄,需要自己設(shè)置GOROOT
3、安裝gcc工具,因?yàn)間olang有些功能是使用c寫
sudo apt-get install bison gawk gcc libc6-dev make
4、$ cd go/src,$ ./all.bash
運(yùn)行bash腳本,如果運(yùn)行正常會(huì)獲得你的操作系統(tǒng)和cpu信息,自動(dòng)編譯安裝
5、將export PATH=$PATH:/usr/local/go/bin 寫入$HOME/.profile
最后進(jìn)行測試輸入go version 會(huì)顯示go1.1.2 linux/386
go語言作為google的一個(gè)主推語言,最近很多人都在研究,也花了一點(diǎn)時(shí)間對(duì)他的安裝進(jìn)行了測試,本人使用Sublime Text 2 + GoSublime + gocode
顧名思義首先是安裝Go,這里有很詳細(xì)的安裝說明, 或者(golang.org自己去找hosts),官方已經(jīng)支持Windows版本
下載解壓配置環(huán)境變量
“環(huán)境變量”(我的電腦-高級(jí)系統(tǒng)設(shè)置-環(huán)境變量),在系統(tǒng)變量的標(biāo)簽下,依次新建編輯如下幾個(gè)鍵值對(duì):
(1). 新建 變量名:GOBIN 變量值 :c:\go\bin
(2). 新建 變量名:GOARCH 變量值:386
(3). 新建 變量名:GOOS 變量值:windows
(4). 新建 變量名: GOROOT 變量值:c:\go
(5). 編輯 Path 在Path的變量值的最后加上 %GOBIN%
1. 下載 Sublime Text 2,地址如下:
2. 解壓以后,雙擊 sublime_text,就可以使用 Sublime Text 2 了。
破解:
用 WinHex 編輯 sublime_text_backup.exe 文件, 跳到 000CBB70 那一行,將該行的 8A C3 修改為 B0 01 然后保存
破解注冊成功
3. 安裝 Package Control,在打開 Sublime Text 2以后,按下快捷鍵 Ctrl + `,打開命令窗行(具體在view——show Console),并回車:
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(‘’+pf.replace(‘ ‘,’%20′)).read()); print ‘Please restart Sublime Text to finish installation’
4. 重啟Sublime Text 2后,就可以發(fā)現(xiàn)在 Preferences菜單下,多出一個(gè)菜單項(xiàng) Package Control。
5.現(xiàn)在安裝GoSublime插件了,按住Ctrl+Shilft+p會(huì)彈出一個(gè)對(duì)話框輸入install回車彈出一個(gè)安裝包的對(duì)話框
同上輸入GoSublime選擇GoSublime回車
本機(jī)已經(jīng)安裝所以沒有出現(xiàn)選項(xiàng),輸入Go build選中回車(這個(gè)屬于可選)
到此GoSublime安裝成功
6.下面安裝gocode,
首安裝 Git-1.7.11-preview20120710。
打開控制臺(tái),輸入以下內(nèi)容:
go get github.com/nsf/gocode
go install github.com/nsf/gocode
go get github.com/DisposaBoy/MarGo
go install github.com/DisposaBoy/MarGo
也可以去github下載(要安裝google的git版本管理工具)
安裝完成后,我們可以在 go/bin 目錄下,發(fā)現(xiàn)多出了個(gè) gocode 文件。(一定要放在bin目錄下)
7. 修改GoSublime配置:在 Preferences菜單下,找到Package Settings,然后找到 GoSublime,再往下找到 Settings – Default。再打開的文件中,添加如下配置,并保存:
"env": {"path":"c:/go/bin;" },
好了,到目前為止,開發(fā)環(huán)境搭建完成。
下面可以自由編程了。呵呵。
按下快捷鍵 Ctrl + b 界面下方會(huì)出現(xiàn)如下界面:
好了,到現(xiàn)在,開發(fā)環(huán)境就搭建完畢了。
如下是內(nèi)容我這邊沒有使用照樣可以使用:
sublime Text 2 編譯配置設(shè)置方法
tools-build system-new build system 新建一個(gè)配置文件 設(shè)置為
{
“cmd”: ["go", "run", "$file_name"],
“file_regex”: “^[ ]*File \”(…*?)\”, line ([0-9]*)”,
“working_dir”: “$file_path”,
“selector”: “source.go”
}
然后就可以用ctrl+b 編譯了
保存
前言:
本Python,學(xué)golang,下筆記,供分享
Go語言,我們可以簡單的寫成 Golang
自行百度吧,不難