GoLang常用框架
Gin web框架
参考文档:
https://gin-gonic.com/docs/quickstart/
$ go install github.com/gin-gonic/gin
$ mkdir -p /www/go/src/gin
$ cd /www/go/src/gin && go mod init gin
$ curl https://raw.githubusercontent.com/gin-gonic/examples/master/basic/main.go > main.go
$ go get github.com/beego/beego/v2/server/web
$ go run gin.go
$ nohup go run gin.go > gin.log 2>&1 &
访问 http://127.0.0.1:8080
Buffalo web框架
参考文档: https://gobuffalo.io/documentation/getting_started/installation/
更新yarn版本:
$ apt remove cmdtest
$ apt remove yarn
$ curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
$ echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
$ apt-get update
$ apt-get install yarn -y
$ wget https://github.com/gobuffalo/cli/releases/download/v0.18.5/buffalo_0.18.5_Linux_x86_64.tar.gz
$ tar -xvzf buffalo_0.18.5_Linux_x86_64.tar.gz
$ sudo mv buffalo /usr/local/bin/buffalo && sudo chmod 777 /usr/local/bin/buffalo
$ buffalo version
$ cd /www/go/src/buffalo
$ buffalo new buffalo
$ cd buffalo && buffalo dev
$ PORT=3001 buffalo dev
$ nohup buffalo dev > buffalo.log 2>&1 &
访问 http://127.0.0.1:3001
Beego web框架
参考文档:
https://www.kancloud.cn/hello123/beego/126092
$ go install github.com/beego/bee@latest
$ bee new beego
$ bee api beegoapi
$ nohup bee run > beego.log 2>&1 &
访问: http://127.0.0.1/go/beego
Revel web框架
参考文档:
https://github.com/revel/revel
$ go install github.com/revel/cmd/revel@latest
$ revel new -a revel
$ go get github.com/revel/revel
$ revel run -a revel
$ nohup revel run -a revel > revel.log 2>&1 &
访问: http://127.0.0.1:9000