首页 > IT职业 > IT图书 > 在Go语言中我为什么选择Iris web框架?
最近有同学提到gin和echo,那我来阐述一下我为什么选择Iris golang web框架的原因,先说说我的观点,先不管Iris是不是全宇宙最快的框架,但iris为了优化性能,不惜自己开发和集成最快的组件,比如日志记录内置了golog模块,比如json序列化就选择了第三方库jsoniter,从框架设计的态度上,我必须给个赞????。
其次Iris是社区驱动的Go语言Web 框架,支持http2,完备 MVC 支持。虽然有点夸张,但iris的确是一个非常优秀的开源web框架,因为优秀,所以选择iris的原因很多,首当其冲的就是他的性能非常卓越,在众多web框架中遥遥领先,感兴趣的同学可以到官网看看基准测试,也可以下载源代码自己跑一下基准测试。另外iris提供的api都是极简风格,很容易上手。第三就是iris强大web功能,支持中间件扩展,并有丰富的中间件生态库。强大的路由功能,可以轻易的构建各种形式的RESTful API,路由分组、静态路由、动态路径参数化、通配符路由等待。还有http错误定义、上下文处理器、身份验证、视图模板、热重启、Websocket支持等等功能,就不一一说了,感兴趣的同学可以到官网一看。选择iris绝对不会错的,放心听我的,使用过程中还会发现一些惊喜的功能。总结下来就是如下几点:
选择一个开源框架除了性能和特性之外,还要考虑社区活跃度和文档支持。
我本来想做个Golang web框架的比较,却发现已近有人做了详细的对比。
先放上官网对几个主要的go web框架性能比较的截图,也可以点击链接前往查看https://github.com/kataras/iris#third-party

这个链接也是官网对各种语言的各种web框架做的一个基准测试,内容比较多,点击链接前往查看:
下面就是我说的前人已经做的详细对比,在githu上整理了帅气的优秀golangweb框架和特性比较,点击链接前往查看原文:
下面是翻译稿,出处是https://studyiris.com
下面是摘录的核心特征的比较表格:
Sorted by the most to less featured
| Name | Iris | Beego | Revel | Echo | Gin | Buffalo |
|---|---|---|---|---|---|---|
| Router: Named Path Parameters & Wildcard* | ![]() | ![]() | ![]() | ![]() | ![]() |
- |
| Router: Regex* | ![]() | ![]() | ![]() | ![]() | ![]() |
- |
| Router: Grouping* | ![]() | ❔ | ❔ | ![]() | ![]() |
- |
| Router: All the above Mixed Without Conflict* | ![]() | ![]() | ![]() | ![]() | ![]() | |
| Router: Custom HTTP Errors* | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 100% compatible with net/http* | ![]() | ![]() | ![]() | ❔ | ![]() | ![]() |
| Middleware ecosystem* | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Sinatra-like API* | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Server: Automatic HTTPS* | ![]() | ❔ | ![]() | ![]() | ![]() | ![]() |
| Server: Gracefully Shutdown* | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Server: Multi Listeners* | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Full HTTP/2* | ![]() | ❔ | ❔ | ![]() | standard | standard |
| Subdomains* | ![]() | secondary | secondary | secondary | secondary | secondary |
| Sessions* | ![]() | ![]() | ![]() | ![]() | ![]() | secondary |
| Websockets* | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| View (aka Templates) Embedded Into App* | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| View Engine: STD* | ![]() | ![]() | ![]() | ![]() | ![]() | |
| View Engine: Pug* | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| View Engine: Django* | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| View Engine: Handlebars* | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| View Engine: Amber* | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Renderer: Markdown, JSON, JSONP, XML…* | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| MVC* | ![]() |
- | generator | ![]() | ![]() | ![]() |
| Caching* | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| File Server* | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| File Server: Embedded Into App* | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Response can be Modified Many times through lifecycle before sent* | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Gzip* | ![]() | ![]() | ![]() | middleware | middleware | middleware |
| Testing Framework* | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Typescript Transpiler* | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Online Editor* | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Logging System* | ![]() | ![]() | ![]() |
- |
- | ![]() |
| Maintenance & Auto-Updates* | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Performance | ★★★★★ | ★★★ | ★★ | ★★★★★ | ★★★★★ | ★★★ |
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2752/viewspace-2822838/ ,如需转载,请注明出处,否则将追究法律责任。