beego绠€浠婞/h2>
Beego鏄竴涓揩閫熷紑鍙慓o搴旂敤鐨刪ttp妗嗘灦锛屽彲鐢ㄤ簬蹇€熷紑鍙慉pi銆亀eb鍙婂悗绔湇鍔$瓑鍚勭搴旂敤锛屾槸涓€涓猂ESTful妗嗘灦銆侟/p>
beego鐨勬灦鏋凕/h2>
Beego鐢卞叓涓嫭绔嬫ā鍧楁瀯寤猴紝鏄竴涓珮搴﹁В鑰︾殑搴旂敤锛岀敤鎴峰彲浠ヤ笉鏄敤beego鐨刪ttp閫昏緫浣跨敤閲岄潰鐨勪换鎰忔ā鍧椼€傚叿浣撴灦鏋勮璁″涓婜
beego鎵ц閫昏緫
beego鏄竴涓粡鍏哥殑mvc妗嗘灦锛屽畠鐨勬墽琛岄€昏緫濡備笅:
涓庝箣瀵瑰簲鐨勯」鐩洰褰曠粨鏋勫涓婜
鈹溾攢鈹€ conf
鈹 鈹斺攢鈹€ app.conf
鈹溾攢鈹€ controllers 鈹 鈹溾攢鈹€ admin 鈹 鈹斺攢鈹€ default.go 鈹溾攢鈹€ main.go 鈹溾攢鈹€ models 鈹 鈹斺攢鈹€ models.go 鈹溾攢鈹€ static 鈹 鈹溾攢鈹€ css 鈹 鈹溾攢鈹€ ico 鈹 鈹溾攢鈹€ img 鈹 鈹斺攢鈹€ js 鈹斺攢鈹€ views 鈹溾攢鈹€ admin 鈹斺攢鈹€ index.tpl
鎴戜滑鍙互鐪嬪嚭mian.go鏄叆鍙f枃浠讹紝controllers鏄€昏緫鎺у埗妯″潡锛宮odels鏄ā鍨嬫ā鍧楋紝views鏄鍥炬ā鍧椼€侟/p>
beego鐨勫畨瑁匋/h2>
beego妗嗘灦鐨勫畨瑁呮柟娉曢潪甯哥畝鍗曪紝浣跨敤涓€涓嬫寚浠ゅ嵆鍙?/p>
go get github.com/astaxie/beego
go璇█鍦ㄨ繖涓€鐐规垜璁や负鏄仛鐨勬瘮杈冨ソ鐨勶紝鐩存帴鐢ㄦ寚浠ゅ氨鑳界洿鎺ヤ笅杞藉畨瑁呭ソ銆傚綋鐒朵笂杩版寚浠ら渶瑕乬it鏀寔銆傜敤鎴峰悓鏍峰彲浠ュ湪github涓婁笅杞芥簮浠g爜鐒跺悗鏀剧疆鍒癎OPATH涓嬬殑src/github.com/astaxie/鐩綍涓嬶紝鐒跺悗浣跨敤go install
灏卞彲鐩存帴瀹夎銆侟/p>
beego杩樻湁涓€涓伐鍏穊ee鐢ㄤ簬鍗忓姪蹇€熷紑鍙慴eego椤圭洰锛岄€氳繃bee鍙互寰堝鏄撶殑杩涜鏋勫缓銆佺儹缂栬瘧銆佸紑鍙戙€佹祴璇曞拰閮ㄧ讲銆?nbsp;
bee宸ュ叿鍙互浣跨敤go鎸囦护鐩存帴涓嬭浇瀹夎:
go get github.com/beego/bee
閮ㄥ垎鐢ㄦ埛鍙兘鍦ㄥ畨瑁呬簡bee宸ュ叿鍚庤繍琛宐ee鏃朵細閬囧埌琚郴缁焝illed鐨勯棶棰橈紝杩欎釜闂浣滆€呬篃娌¤鏄庡叿浣撴槸浠€涔堝師鍥狅紝閬囧埌杩欑闂鐨勭敤鎴峰彲浠ョ洿鎺ヤ粠github.com/beego/bee涓奵lone涓嬭浇鏈€鏂版簮鐮佸埌GOPATH\src\github.com\beego\涓嬬劧鍚巆heckout hot-fix-support鍒嗘敮锛岀劧鍚庢墽琛孅code>go install鎸囦护杩涜鎵嬪姩瀹夎鍗冲彲銆?nbsp;
鎵ц
bee version
鑻ュ嚭鐜颁互涓嬩俊鎭究璇存槑瀹夎鎴愬姛涓旇繍琛屾甯氟
$ bee version
______
| ___ \
| |_/ / ___ ___
| ___ \ / _ \ / _ \ | |_/ /| __/| __/ \____/ \___| \___| v1.8.1 鈹溾攢鈹€ Beego : Beego is not installed. Please do consider installing it first: https://github.com/astaxie/beego 鈹溾攢鈹€ GoVersion : go1.8 鈹溾攢鈹€ GOOS : darwin 鈹溾攢鈹€ GOARCH : amd64 鈹溾攢鈹€ NumCPU : 4 鈹溾攢鈹€ GOPATH : /Users/alpher/go 鈹溾攢鈹€ GOROOT : /usr/local/Cellar/go/1.8/libexec 鈹溾攢鈹€ Compiler : gc 鈹斺攢鈹€ Date : Wednesday, 5 Apr 2017
鍒涘缓beego椤圭洰
瀹夎瀹屼互涓婂伐鍏锋垜浠氨鍙互鐩存帴閫氳繃bee new projectName
鏉ユ瀯寤轰竴涓猙eego妗嗘灦鐨勯」鐩?/p>
$ bee new beegoDemo
______
| ___ \
| |_/ / ___ ___
| ___ \ / _ \ / _ \
| |_/ /| __/| __/
\____/ \___| \___| v1.8.1
2017/04/05 10:24:49 INFO 鈻 0001 Creating application...
create /Users/alpher/go/src/beegoDemo/ create /Users/alpher/go/src/beegoDemo/conf/ create /Users/alpher/go/src/beegoDemo/controllers/ create /Users/alpher/go/src/beegoDemo/models/ create /Users/alpher/go/src/beegoDemo/routers/ create /Users/alpher/go/src/beegoDemo/tests/ create /Users/alpher/go/src/beegoDemo/static/ create /Users/alpher/go/src/beegoDemo/static/js/ create /Users/alpher/go/src/beegoDemo/static/css/ create /Users/alpher/go/src/beegoDemo/static/img/ create /Users/alpher/go/src/beegoDemo/views/ create /Users/alpher/go/src/beegoDemo/conf/app.conf create /Users/alpher/go/src/beegoDemo/controllers/default.go create /Users/alpher/go/src/beegoDemo/views/index.tpl create /Users/alpher/go/src/beegoDemo/routers/router.go create /Users/alpher/go/src/beegoDemo/tests/default_test.go create /Users/alpher/go/src/beegoDemo/main.go 2017/04/05 10:24:49 SUCCESS 鈻 0002 New application successfully created!
椤圭洰鍒涘缓濂藉悗锛屾垜浠渶瑕佽繘鍏ュ埌椤圭洰涓紝浣跨敤bee run projectName
杩愯鏂板垱寤虹殑beego椤圭洰锛屼娇鐢?code>bee run鍛戒护鐨勭洰鐨勬槸杈惧埌鐑紪璇戠殑鏁堟灉锛岃兘瀹炴椂鏌ョ湅鍒版垜浠慨鏀圭殑鍐呭鏁堟灉銆侟/p>
$ bee run beegoDemo
______
| ___ \
| |_/ / ___ ___
| ___ \ / _ \ / _ \
| |_/ /| __/| __/
\____/ \___| \___| v1.8.1
2017/04/05 10:29:29 INFO 鈻 0001 Using 'beegoDemo' as 'appname' 2017/04/05 10:29:29 INFO 鈻 0002 Initializing watcher... beegoDemo/controllers beegoDemo/routers beegoDemo 2017/04/05 10:29:31 SUCCESS 鈻 0003 Built Successfully! 2017/04/05 10:29:31 INFO 鈻 0004 Restarting 'beegoDemo'... 2017/04/05 10:29:31 SUCCESS 鈻 0005 './beegoDemo' is running... 2017/04/05 10:29:31 [I] [asm_amd64.s:2197] http server Running on http://:8080
杩欐牱鎴戜滑鐨勫簲鐢ㄥ氨宸茬粡鍦?080绔彛杩愯浜嗭紝璁块棶localhost:8080灏卞彲浠ョ湅鍒板涓嬫晥鏋滀簡: