Beego和Gin的比较

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Beego和Gin的比较相关的知识,希望对你有一定的参考价值。

参考技术A go的框架大大小小也不少。小马这段时间小复习了下gin,以及结合前段时间的短暂和beego相处的时间,于是产生了如文章标题的问题。以下内容来自 这里 。

给小马的最大感受就是gin需要自己二次封装成企业级脚手架来使用,不直接支持MVC。gin的中间件和验证结构体蛮好用的。

相关教程:

gin的脚手架二次封装参考教程 (视频)

gin中文文档

beego文档

go教程

go标准库文档

使用beego/bee热启动gin框架

1.需要关闭gomod

export GO111MODULE=off

2.安装 bee

go get -u github.com/beego/bee

3.再开启gomod

export GO111MODULE=on

4.启动服务

bee run

haima@haima-PC:~/go/src/haimait/gin_web$ bee run
______
| ___ | |_/ /  ___   ___
| ___  / _  / _ | |_/ /|  __/|  __/
\____/  \___| \___| v1.10.0
2020/02/18 23:06:45 INFO     ? 0001 Using 'gin_web' as 'appname'
2020/02/18 23:06:45 INFO     ? 0002 Initializing watcher...
github.com/haimait/gin_web/pkg/e
github.com/go-ini/ini
github.com/haimait/gin_web/lib/cache
github.com/go-sql-driver/mysql
github.com/jinzhu/gorm
github.com/haimait/gin_web/lib/jwt
github.com/haimait/gin_web/api/service
github.com/haimait/gin_web/lib/apilog
github.com/haimait/gin_web/lib/httpext
github.com/pkg/errors
github.com/lestrrat/go-strftime
github.com/haimait/gin_web/conf
github.com/lestrrat/go-file-rotatelogs
github.com/haimait/gin_web/api/middleware
github.com/haimait/gin_web/api/model
github.com/haimait/gin_web/api/controller
github.com/haimait/gin_web/router
github.com/haimait/gin_web
2020/02/18 23:06:50 SUCCESS  ? 0003 Built Successfully!
2020/02/18 23:06:50 INFO     ? 0004 Restarting 'gin_web'...
2020/02/18 23:06:50 SUCCESS  ? 0005 './gin_web' is running...
[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.

[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:   export GIN_MODE=release
 - using code:  gin.SetMode(gin.ReleaseMode)

0.0.0.0
8822
[GIN-debug] GET    /user/create_user         --> github.com/haimait/gin_web/api/controller.CreateUser (8 handlers)
[GIN-debug] GET    /token/create             --> github.com/haimait/gin_web/api/controller.CreateToken (8 handlers)
[GIN-debug] GET    /test/response            --> github.com/haimait/gin_web/api/controller.Response (8 handlers)
[GIN-debug] GET    /test/testlog             --> github.com/haimait/gin_web/api/controller.TestLog (8 handlers)
[GIN-debug] GET    /test/getconfig           --> github.com/haimait/gin_web/api/controller.GetConfig (8 handlers)
[GIN-debug] POST   /test/testvalid1          --> github.com/haimait/gin_web/api/controller.TestValid1 (9 handlers)
[GIN-debug] Listening and serving HTTP on 0.0.0.0:8822

以上是关于Beego和Gin的比较的主要内容,如果未能解决你的问题,请参考以下文章

Go语言框架:Beego vs Gin 的区别

golang 都有哪些比较稳定的 web 开发框架

gozero和gin性能对比

大家觉得用Go做WEB有必要用框架吗

2021-05-21 对比GO的Web框架Gin和Beego

2021-05-21 对比GO的Web框架Gin和Beego