发布日期: 2019-11-28
版本号: v1.5.0

Gin框架本次更新包含多项新功能与问题修复。新增功能包括支持解析行内小写结构、存储完整匹配路由路径、添加查询参数缓存、支持多文件上传、绑定HTTP请求头参数、支持Unix时间格式、允许负值Content-Length、JSON绑定禁止未知字段以及指定网络监听器等。修复方面重点解决了调试信息输出异常、JSON编码性能优化、路由参数竞争条件、POST数据处理漏洞、内存泄漏问题,并停止支持Go 1.8/1.9版本,调整JSONP回调格式要求,升级验证器版本至v9。同时改进了RISC-V架构终端识别、日志构建效率,修正了多处拼写错误,并对文件描述符关闭、表单字段过滤等细节进行了优化,部分改动存在不向下兼容的情况。

更新内容 (中文)

新特性

  • [新增] 支持解析行内小写起始结构 #1893
  • [新增] [破坏性变更] 在上下文中保留完整匹配路由路径 #1826
  • [新增] 添加上下文参数查询缓存 #1450
  • [新增] 支持多部分多文件上传 #1949
  • [新增] 支持绑定HTTP头部参数 #1957
  • [新增] 支持绑定UNIX时间格式 #1980
  • [新增] 支持DataFromReader中负值的Content-Length #1981
  • [新增] 在gin.Context.BindJSON()中添加DisallowUnknownFields()方法 #2028
  • [新增] 通过Engine.RunListener()使用特定网络监听器 #2023

问题修复

  • [修复] 调试信息使用DefaultWriter和DefaultErrorWriter #1891
  • [修复] 代码优化改进 #1909
  • [修复] 使用编码器替代JSON序列化提升性能 #1546
  • [修复] 修复Copy()方法中的上下文参数竞态问题 #1841
  • [修复] 提升GetQueryMap性能 #1918
  • [修复] 改进POST数据获取方式 #1920
  • [修复] 使用标准库context替代x/net/context #1922
  • [修复] 尝试修复PostForm缓存问题 #1931
  • [修复] [破坏性变更] 停止支持Go1.8和Go1.9版本 #1933
  • [修复] FullPath特性的错误修复 #1919
  • [修复] Gin1.5版本将bytes.Buffer替换为strings.Builder #1939
  • [修复] 升级ugorji/go/codec依赖 #1969
  • [修复] 代码简化 #2004
  • [修复] 识别RISC-V架构终端以自动着色日志 #2019
  • [修复] [破坏性变更] JSONP方法现在要求结尾分号(;) #2007
  • [修复] [破坏性变更] 升级验证器版本至v9 #1015
  • [修复] 修正拼写错误 #2079 #2080
  • [修复] 调整绑定体测试位置 #2086
  • [修复] 在Context.Status中使用Writer #1606
  • [修复] Engine.RunUnix()现在返回文件模式修改错误 #2093
  • [修复] RouterGroup.StaticFS()文件泄漏问题,现已关闭文件 #2118
  • [修复] Context.Request.FormFile文件泄漏问题,现已关闭文件 #2114
  • [修复] 忽略form:"-“标签的映射 #1943
  • [重构] [破坏性变更] 使用编码器替代JSON序列化提升性能 #1546

更新内容 (原始)

Feature

  • [NEW] Now you can parse the inline lowercase start structure #1893
  • [NEW] [Break-Backward] Hold matched route full path in the Context #1826
  • [NEW] Add context param query cache #1450
  • [NEW] Add support of multipart multi files #1949
  • [NEW] Support bind http header param #1957
  • [NEW] Support bind unix time #1980
  • [NEW] Support negative Content-Length in DataFromReader #1981
  • [NEW] Add DisallowUnknownFields() in gin.Context.BindJSON() #2028
  • [NEW] Use specific net.Listener with Engine.RunListener() #2023

Bug fix

  • [FIX] Use DefaultWriter and DefaultErrorWriter for debug messages #1891
  • [FIX] Some code improvements #1909
  • [FIX] Use encode replace json marshal increase json encoder speed #1546
  • [FIX] Fix context.Params race condition on Copy() #1841
  • [FIX] Improve GetQueryMap performance #1918
  • [FIX] Improve get post data #1920
  • [FIX] Use context instead of x/net/context #1922
  • [FIX] Attempt to fix PostForm cache bug #1931
  • [FIX] [Break-Backward] Drop support for go1.8 and go1.9 #1933
  • [FIX] Bugfix for the FullPath feature #1919
  • [FIX] Gin1.5 bytes.Buffer to strings.Builder #1939
  • [FIX] Upgrade github.com/ugorji/go/codec #1969
  • [FIX] Simplify code #2004
  • [FIX] Identify terminal on a RISC-V architecture for auto-colored logs #2019
  • [FIX] [Break-Backward] Context.JSONP() now expects a semicolon (;) at the end #2007
  • [FIX] [Break-Backward] Upgrade validator version to v9 #1015
  • [FIX] Fix some typo #2079 #2080
  • [FIX] Relocate binding body tests #2086
  • [FIX] Use Writer in Context.Status #1606
  • [FIX] Engine.RunUnix() now returns the error if it can’t change the file mode #2093
  • [FIX] RouterGroup.StaticFS() leaked files. Now it closes them. #2118
  • [FIX] Context.Request.FormFile leaked file, now it closes it #2114
  • [FIX] Ignore walking on form:"-" mapping #1943
  • [REFACTOR] [Break-Backward] Use encode replace json marshal increase json encoder speed #1546

下载链接