GO鈥斺€攂eego瀹夎鍙婃柊寤洪」鐩紙涓€锛

时光怂恿深爱的人放手 提交于 2020-04-28 07:32:03

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灏卞彲浠ョ湅鍒板涓嬫晥鏋滀簡:

瑙夊緱涓嶉敊锛岀粰鎴戜竴鐐逛互澶竵鍚 鍦板潃锛?xF23FCCbF5A4ee9832CC553c63732BAdfc606A2c2
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!