Go語言開發環境搭建-(1)
安裝包下載目錄地址: https://studygolang.com/dl ,選穩定版本的 go1.12.windows-amd64.msi 。go1.12.windows-amd64.msi,安裝步驟和大部分windows其它軟體一樣,一步步直到最後完成。
https://studygolang.com/dl/golang/go1.12.windows-amd64.msi
go1.12.windows-amd64.msi Installer Windows x86-64 117MB 13515401fc5e8e2959ee37413f9d2af934e2bfbba87a2a4d7a1c6058a9dbe6d5
hello.go package main import "fmt" func main(){ fmt.Printf("hello,world team!\n") }
安裝beego環境
參考網址: https://beego.me
首先,下載並安裝好GO並配置好GOROOT和GOPATH環境變數(如果您是用 msi 包安裝的go,那麼這些環境變數已經設定好了)。並在Path環境變數中加入%GOPATH%\bin和%GOROOT%bin。
第二步,下載並安裝好git bash工具。
第三步,開啟gitbash,輸入 go get github.com/astaxie/beego 。稍等片刻即可在GOPATH的src目錄下看到有\ github.com \astaxie\beego目錄。
第四步,在gitbash中輸入 go get github.com/beego/bee 。稍等片刻即可在GOPATH的src目錄下看到有\ github.com \beego\bee目錄,同時有很多依賴包被下載新增到\ github.com 目錄下。
其中報錯:
D:\goprojects>go get github.com/beego/bee
# cd .; git clone https://github.com/beego/bee D:\goprojects\src\ github.com \beeg
o\bee
Cloning into 'D:\goprojects\src\ github.com \beego\bee'...
fatal: unable to access ' https://github.com/beego/bee/ ': OpenSSL SSL_connect: SS
L_ERROR_SYSCALL in connection to github.com:443
package github.com/beego/bee : exit status 128
D:\goprojects>
可以在能執行 git clone的linux環境下,把安裝目錄copy下來,然後放到提示的目錄上。
之後執行go build -i,才能生成bee.exe工具元件
測試bee是否安裝成功,可在命令列中輸入bee,得到如下結果就成功了,如下所示: