栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Go语言

当前流行的Go web框架比较以及Gin介绍

Go语言 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

当前流行的Go web框架比较以及Gin介绍

当前流行的Go语言web框架

以下是截止到2021.10.03,GitHub上开源的Go Web框架情况。目前Gin是遥遥领先。

Project NameStarsForksOpen IssuesDescriptionLast Commit
gin518945889443Gin is a HTTP web framework written in Go (Golang). It features a Martini-like API with much better performance -- up to 40 times faster. If you need smashing performance, get yourself some Gin.2021-09-30 02:04:28
beego27032531627beego is an open-source, high-performance web framework for the Go programming language.2021-09-18 15:08:26
kit21360219247A standard library for microservices.2021-09-28 15:01:29
echo20797184165High performance, minimalist Go web framework2021-09-26 15:56:43
fasthttp16135133646Fast HTTP package for Go. Tuned for high performance. Zero memory allocations in hot paths. Up to 10x faster than net/http2021-10-01 11:38:31
fiber1559078937⚡️ Express inspired web framework written in Go2021-10-02 01:54:34
mux15202141324A powerful HTTP router and URL matcher for building Go web servers with 轢2021-09-14 12:12:19
kratos14913300135A Go framework for microservices.2021-09-30 06:31:25
httprouter13204127563A high performance HTTP request router that scales well2020-09-21 13:50:23
revel124001402103A high productivity, full-stack web framework for the Go language.2020-07-12 05:57:36
go-zero11533137234go-zero is a web and rpc framework written in Go. It's born to ensure the stability of the busy sites with resilient design. Builtin goctl greatly improves the development productivity.2021-10-02 10:16:59

Web框架需要做什么

我们先思考下,一个完整的Web开发框架需要做哪些事情

组件功能是否必须
server作为server,监听端口,接受请求是
router路由和分组路由,可以把请求路由到对应的处理函数是
middleware支持中间件,对外部发过来的http请求经过中间件处理,再给到对应的处理函数。例如http请求的日志记录、请求鉴权(比如校验token)、CORS支持、CSRF校验等。是
template engine模板引擎,支持后端代码对html模板里的内容做渲染(render),返回给前端渲染好的html否
ORM对象关系映射,可以把代码里的对象和关系数据库的表、字段做映射关联,通过操作对象来实现数据库的增删查改等操作。否

Gin有什么

Gin的主要作者是Manu,Javier和Bo-Yi Wu,2016年发布第一个版本,目前是最受欢迎的开源Go框架。

Gin除了支持上面表格里列的server、router、middleware和template之外,还支持

  • Crash-free:崩溃恢复,Gin可以捕捉运行期处理http请求过程中的panic并且做recover操作,让服务一直可用。

  • JSON validation:JSON验证。Gin可以解析和验证request里的JSON内容,比如字段必填等。当然开发人员也可以选择使用第三方的JSON validation工具,比如beego validation。

  • Error management:错误管理。Gin提供了一种简单的方式可以收集http request处理过程中的错误,最终中间件可以选择把这些错误写入到log文件、数据库或者发送到其它系统。

  • Middleware Extendtable:可以自定义中间件。Gin除了自带的官方中间件之外,还支持用户自定义中间件,甚至可以把自己开发的中间件提交到官方代码仓库里。

Gin本身不支持ORM,如果想在Gin框架里使用ORM,可以选择使用第三方的ORM,比如gorm。

文章开源地址:

https://github.com/jincheng9/go-tutorial

会有一个系列分享Go Web开发的方方面面。

欢迎大家关注公众号:coding进阶,学习更多Go知识。

References
  • Gin Web Framework

  • https://github.com/mingrammer/go-web-framework-stars

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/907266.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号