1、安装Beego
1、Go 第三方包 go-sqlite3 参考:https://my.oschina.net/Obahua/blog/129689
Mac OS X 通过 Homebrewn 安装:
brew install pkgconfig brew install sqlite3
参考:https://github.com/Unknwon/go-web-foundation/blob/v1/lectures/lecture1/lecture1.md
https://github.com/astaxie/beego
go get github.com/astaxie/beego
2、Beego 运行hello world
package main import( "github.com/astaxie/beego" ) type HomeController struct { beego.Controller } func (this *HomeController) Get(){ this.Ctx.WriteString("hello world") } func main() { beego.Router("/",&HomeController{}) beego.Run() } $go run test.go 2018/07/18 10:59:09.731 [I] http server Running on http://:8080
浏览器访问:http://localhost:8080/ 返回: hello world
2018/07/18 10:59:32.571 [D] ::1 - - [18/Jul/2018 10:59:32] "GET / HTTP/1.1 200 0" 0.002190 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
原文:http://blog.51cto.com/daixuan/2146241