1. 程式人生 > >go語言學習-beego框架學習bee在windows和linux下的安裝

go語言學習-beego框架學習bee在windows和linux下的安裝

windows下的安裝

  • windows下的安裝和linux下其實是相同的命令
go get github.com/beego/bee
//或者使用
go install github.com/beego/bee

在windows下安裝完成之後需要在 環境變數中加入bee的路徑%GOPATH%\bin
這樣做的好處是在任何地方都可以使用 bee 工具
填加完成之後再命令列介面輸入 bee看有沒有成功,成功的話如下:

Bee is a Fast and Flexible tool for managing your Beego Web Application.

USAGE
    bee command
[arguments]
AVAILABLE COMMANDS version Prints the current Bee version migrate Runs database migrations api Creates a Beego API application bale Transforms non-Go files to Go source files fix Fixes your application by making it compatible with newer versions of
Beego dlv Start a debugging session using Delve dockerize Generates a Dockerfile for your Beego application generate Source code generator hprose Creates an RPC application based on Hprose and Beego frameworks new Creates a Beego application pack Compresses a
Beego application into a single file rs Run customized scripts run Run the application by starting a local development server server serving static content over HTTP on port Use bee help [command] for more information about a command. ADDITIONAL HELP TOPICS Use bee help [topic] for more information about that topic.
如果沒有成功重啟電腦看行不行,一般重啟後就會生效

Linux下的安裝

  • linux下安裝和windows命令一樣,這裡就不寫了

可能遇到的問題:

  • 在安裝過程中可能會報下面的錯誤提示:go install: cannot install cross-compiled binaries when GOBIN is set
  • 遇到這個問題一般是在環境變數中設定了 GOBIN 可以開啟 /etc/profile 把這個變數註釋掉就,執行 source /etc/profile生效即可

    同樣安裝完成之後需要在環境變數中追加bee的路徑

  • 在 /etc/profile 檔案中追加 export PATH=$GOPATH/bin:$PATH 之後執行 source /etc/profile 生效
    可能遇到的問題:
  • 新增之後執行bee不成功,檢視bee的所在路徑 :
echo $GOPATH //獲取GOPATH的路徑,我這裡是在/home/chun/go
find /home/chun/go -name "bee"

輸出:

/home/chun/go/bin/linux_386/bee
/home/chun/go/src/github.com/beego/bee
/home/chun/go/pkg/linux_386/github.com/beego/bee

這裡可以看到我的linux系統上bee的安裝路徑和正常不一樣,在linux_386下面,接下來只需要把/home/chun/go/bin/linux_386新增到環境變數就ok了

export PATH=$GOPATH/bin/linux_386:$PATH

source /etc/profile

這樣就OK了,如果還有問題歡迎留言