beego 是一個快速開發 Go 應用的 HTTP 框架,他能夠用來快速開發 API、Web 及後端服務等各類應用,是一個 RESTful 的框架,主要設計靈感來源於 tornado、sinatra 和 flask 這三個框架,可是結合了 Go 自己的一些特性(interface、struct 嵌入等)而設計的一個框架。linux
go get github.com/astaxie/beego
更多安裝信息:https://beego.me/docs/install/git
go get github.com/beego/bee
安裝完以後,bee 可執行文件默認存放在 $GOPATH/bin 裏面,因此您須要把 $GOPATH/bin 添加到您的環境變量中,才能夠進行下一步,以下所示:github
(1)當前環境變量(Xshell 退出從新登陸後失效)golang
export PATH=$PATH:/home/www/golang/gopath/bin/linux_386
疑問:我這裏怎麼多出來一個linux_386(??) shell
(2)全局環境變量修改(Xshell 退出從新登陸後不失效)flask
sudo vim /etc/profile // 添加如下內容 export PATH=$PATH:/home/www/golang/gopath/bin/linux_386 // 編輯結束後執行 source profile 或 執行點命令 ./profile, PATH的值就會當即生效了 source /etc/profile
(3)關於 /etc/profile 和 ./profile 設置的區別vim
(4)環境變量沒有安裝成功的話會出現如下狀況後端
bee new hello No command 'bee' found, did you mean: Command 'tee' from package 'coreutils' (main) Command 'beef' from package 'beef' (universe) Command 'ree' from package 'ree' (universe) Command 'btee' from package 'ruby-bcat' (universe) Command 'beer' from package 'gerstensaft' (universe) Command 'pee' from package 'moreutils' (universe) Command 'bbe' from package 'bbe' (universe) Command 'be' from package 'bugs-everywhere' (universe) Command 'beep' from package 'beep' (universe) Command 'see' from package 'mime-support' (main) Command 'ben' from package 'ben' (universe) Command 'bel' from package 'belier' (universe) Command 'beet' from package 'beets' (universe) bee: command not found
bee new hello
記住:要進入剛建立的新項目hello瀏覽器
/home/www/golang/gopath/src/hello/ www@TinywanAliYun:~/golang/gopath/src/hello$ ls conf controllers main.go models routers static tests views www@TinywanAliYun:~/golang/gopath/src/hello$ bee run
http://edu.51cto.com/center/course/lesson/index?id=24341ruby
文件目錄結構
Linux 配置環境變量
export GOPATH=/home/www/golang/gopath export GOROOT=/usr/local/go export GOTOOLS=$GOROOT/pkg/tool export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
Windows 配置環境變量