GO環境搭建

環境搭建:

[https://github.com/astaxie/build-web-application-with-golang/blob/master/zh/01.4.md](https://github.com/astaxie/build-web-application-with-golang/blob/master/zh/01.4.md)

1、安裝gosubmile

【gosublime自動安裝失敗,手動安裝】

參考:[https://note.youdao.com/ynoteshare1/index.html?id=2468dc1652bd08f6ab28ca81617ec1f6&type=note](https://note.youdao.com/ynoteshare1/index.html?id=2468dc1652bd08f6ab28ca81617ec1f6&type=note)

點擊菜單: Preferences --> Browse Packages

打開Packages directory

打開Bit Bash Here ,git clone gosublime 包

git clone git@github.com:DisposaBoy/GoSublime.git在 GoSublime\src 源代碼目錄中,新建 margo 子目錄

將 GoSublime\src\margo.sh\extension-example 目錄下的 extension-example.go 文件復制到

GoSublime\src\margo 目錄 ,并改名 margo.go

重啟 Sublime Text3 。

點擊菜單項Preferences -> package settings -> GoSublime -> Settings - Uesrs,

配置GOPATH,GOROOT:

{

"env": {

    "GOPATH": "F:/WORKSPACE/go-space", ##源碼的頂級工作空間,注意必須放在src包下,否則運行錯誤

    "GOROOT": "e:/go"

},

"font_size": 14,

"highlight_line": true,

"highlight_modified_tabs": true,

"ignored_packages":

[

    "Vintage"

],

"soda_classic_tabs": true,

"soda_folder_icons": true,

"tab_size": 4,

"translate_tabs_to_spaces": true,

"update_check": false,

"word_wrap": true

}

快捷鍵

  • 在sublime打開控制臺 Ctrl + B

  • 關閉sbulime中打開的控制臺 Esc

  • 查看函數的聲明 Ctrl + . + H

  • 查看函數源碼 Ctrl + . + G

  • 調出GoSublime 支持的所有功能: cmd +.


2、安裝SidebarEnhancements和Go Build


3、安裝 gocode

go get -u github.com/nsf/gocode

gocode 將會安裝在默認$GOBIN

另外建議安裝gotests(生成測試代碼):

先在sublime安裝gotests插件,再運行:

go get -u -v github.com/cweill/gotests/...


4、安裝Goimports:可以在開發過程時候自動引入包和刪除沒有使用的包

4.1 下載goimports

創建文件夾

mkdir $GOPATH/src/golang.org/x/

進入文件夾 cd $GOPATH/src/golang.org/x/

下載源碼

git clone https://github.com/golang/tools.git

安裝

go install golang.org/x/tools/cmd/goimports

4.2 安裝后打開 GoSublime 的配置文件,在配置文件中添加新的根配置項:

{

"fmt_cmd" :[ "goimports"]

}


5、新加一個Build System支持CTRL+B進行編譯

image
image.gif

?


最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。