標籤:android style blog class code ext
本文介紹兩種Golang的開發環境一種基於notepad++、另一種基於liteide。
1、下載Golang語言的pkg:http://golangtc.com/download
直接點擊安裝,一路next。
2、程式員必備神器notepad++開發Golang環境很簡單
一次點擊:外掛程式->Plugin Manger->Show Plugin Manger,安裝外掛程式GOnpp,重啟notepad++。
建立檔案命名為hello.go用notepad++開啟,拷貝如下代碼:
package mainimport "fmt"func main() {fmt.Println("Hello, 世界")}依次點擊:外掛程式->GOnpp->go run;大功告成。
3、下面介紹notepad++高亮顯示golang關鍵字的方法:
語言->自訂語言->匯入檔案(C:\Go\misc\notepadplus\userDefineLang.xml要去掉開頭結尾的注釋)
拷貝C:\Go\misc\notepadplus\go.xml到C:\Program Files\Notepad++\plugins\APIs;ok,又大功告成,趕緊試一下吧。
4、接下來介紹基於整合式開發環境LiteIDE
下載解壓,直接運行搞定,記得配置GOPATH系統內容變數。
說明martini的使用:
package mainimport "github.com/go-martini/martini"func main() {m := martini.Classic()m.Get("/", func() string {return "Hello world!"})m.Run()}採用martini搭建一個web環境。
建立檔案拷貝以上檔案到main.go中,如果直接運行會發現缺少依賴包。
採用LiteIDE的get命令擷取依賴包,就是這個按鈕。
編譯運行,程式輸出:[martini] listening on :3000
採用瀏覽器訪問一下: