Golang入門教程(三)beego 架構安裝

來源:互聯網
上載者:User
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。

  beego 是一個快速開發 Go 應用的 HTTP 架構,他可以用來快速開發 API、Web 及後端服務等各種應用,是一個 RESTful 的架構,主要設計構想來源於 tornado、sinatra 和 flask 這三個架構,但是結合了 Go 本身的一些特性(interface、struct 嵌入等)而設計的一個架構。

步驟:

  1. 安裝 beego 到您的 $GOPATH 中。
  2. 在您的電腦上安裝 Bee 工具。
  3. 建立一個名為 “hello” 的應用程式。
  4. 啟動熱編譯。

1、beego 的安裝

go get github.com/astaxie/beego

更多安裝資訊:https://beego.me/docs/install/

2、bee 工具的安裝

go get github.com/beego/bee

安裝完之後,bee 可執行檔預設存放在 $GOPATH/bin 裡面,所以您需要把 $GOPATH/bin 添加到您的環境變數中,才可以進行下一步,如下所示:

export PATH=$PATH:/home/www/golang/gopath/bin/linux_386

疑問:我這裡怎麼多出來一個linux_386(??) 

環境變數沒有安裝成功的話會出現以下情況

bee new helloNo 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

3、建立項目

bee new hello

4、執行項目

記住:要進入剛建立的新項目hello

/home/www/golang/gopath/src/hello/www@TinywanAliYun:~/golang/gopath/src/hello$ lsconf  controllers  main.go  models  routers  static  tests  viewswww@TinywanAliYun:~/golang/gopath/src/hello$ bee run

5、開啟瀏覽器看看效果

 

6、視頻教程

http://edu.51cto.com/center/course/lesson/index?id=24341

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.