---
title: "v1.10 2019-12-05"
url: "https://goframe.org/release/v1.10.0"
markdown_url: "https://goframe.org/release/v1.10.0.md"
locale: "zh-Hans"
version: "2.10.x(Latest)"
section: "版本发布记录"
category: "版本发布记录 / 历史版本记录 v1.x"
published: "2024-11-04"
updated: "2024-11-18"
description: "GoFrame 框架推出 v1.10 版本，为开发者带来了多个新特性和改进。这次更新包括 WebServer 中间件和路由实现优化、增加文件配置管理、Session 多种存储实现、日志组件单例对象、JSON 数据格式支持、guuid 模块用于 UUID 生成，数据库、网络、容器等多个模块的性能改进，进一步提高了操作效率和开发体验。"
keywords: ["GoFrame", "WebServer", "Session Storage", "日志组件", "JSON 数据格式", "guuid 模块", "数据库改进", "ghttp 改进", "container 改进", "gconv 性能优化"]
---

# v1.10 2019-12-05

各位 `gfer` 久等了，较上一次发布时间过去已有两个多月了，这段时间 `GoFrame` 也在不断地迭代改进，细节比较多，拟了个大概，以下是 `release log`。

另外， `GoFrame` 也参加了2019最受欢迎中国开源软件评选投票，明天就结束了，欢迎为 `GoFrame` 投票啊： [https://www.oschina.net/project/top\_cn\_2019](https://www.oschina.net/project/top_cn_2019) 网页可以投一票，微信也可以投一票。

### 新特性

1. `WebServer` 新特性：
   - 改进中间件及分组路由实现： [https://goframe.org/net/ghttp/router/middleware](https://wiki.goframe.org/net/ghttp/router/middleware)
   - 增加文件配置管理特性： [https://goframe.org/net/ghttp/config](https://wiki.goframe.org/net/ghttp/config)
   - 改进参数获取： [https://goframe.org/net/ghttp/request/index](https://wiki.goframe.org/net/ghttp/request/index)
   - 改进文件上传： [https://goframe.org/net/ghttp/client/demo/upload](https://wiki.goframe.org/net/ghttp/client/demo/upload)
2. `Session` 增加内置的多种 `Storage` 实现：
   - 基本介绍： [https://goframe.org/os/gsession/index](https://wiki.goframe.org/os/gsession/index)
   - 文件存储： [https://goframe.org/os/gsession/file](https://wiki.goframe.org/os/gsession/file)
   - 内存存储： [https://goframe.org/os/gsession/memory](https://wiki.goframe.org/os/gsession/memory)
   - `Redis` 存储： [https://goframe.org/os/gsession/redis](https://wiki.goframe.org/os/gsession/redis)
3. 增加日志组件单例对象，并优化配置管理：
   - [https://goframe.org/frame/g/index](https://wiki.goframe.org/frame/g/index)
   - [https://goframe.org/os/glog/config](https://wiki.goframe.org/os/glog/config)
4. 常用的 `container` 容器增加 `JSON` 数据格式的 `Marshal`/ `UnMarshal` 接口实现：
   - [https://goframe.org/container/gmap/index](https://wiki.goframe.org/container/gmap/index)
   - [https://goframe.org/container/garray/index](https://wiki.goframe.org/container/garray/index)
   - [https://goframe.org/container/gset/index](https://wiki.goframe.org/container/gset/index)
   - [https://goframe.org/container/gvar/index](https://wiki.goframe.org/container/gvar/index)
   - [https://goframe.org/container/gtype/index](https://wiki.goframe.org/container/gtype/index)
   - [https://goframe.org/container/glist/index](https://wiki.goframe.org/container/glist/index)
   - [https://goframe.org/container/gvar/index](https://wiki.goframe.org/container/gvar/index)
5. 新增 `guuid` 模块，用于通用的 `UUID` 生成： [https://goframe.org/util/guuid/index](https://wiki.goframe.org/util/guuid/index)

### 功能改进

#### `net`

1. `ghttp`
   - 改进请求流程处理性能；
   - `Server` 增加对 `Logger` 日志对象的配置；
   - `Server` 开放了 `GetRouterMap` 方法，用于获得当前服务的路由列表信息，使得开发者可以更方便地实现自定义权限管理；
   - `Server` 配置管理优化；
   - `Client` 客户端对象进行了大量的改进工作；
   - `Client` 客户端对象增加多文件上传功能；
   - `Request` 对象增加 `GetError` 方法，用于获取当前处理错误；
   - `Request` 对象增加独立的视图对象及视图变量绑定功能，使得每个请求可以独立视图管理，也可以通过中间件切换请求对象的视图对象。默认情况下该功能关闭，视图解析时使用的是 `Server` 对象的视图对象；
   - 改建 `Response` 对象的 `CORS` 功能；
   - 增加 `Response.WriteTplDefault` 方法，用于解析并返回默认的模板内容；
   - 增加更多的单元测试用例；
   - 其他改进；
2. `gipv4`/ `gipv6`
   - 一些改进工作；
3. `gtcp`/ `gudp`
   - 一些改进工作；

#### `database`

1. `gdb`
   - 大量细节改进工作；
   - 去掉查询数据为空时的 `sql.ErrNoRows` 错误返回，保留 `Struct`/ `Structs`/ `Scan` 方法在操作数据为空的该错误返回；
   - 调试模式开启时，输出的SQL语句改进为完整的带参数的SQL，仅作参考；
   - `Where` 方法增加对 `gmap` 数据类型支持，包括顺序性的 `ListMap`/ `TreeMap` 等等；
   - 查询缓存方法 `Cache` 的缓存时间参数类型修改为 `time.Duration`；
   - 修改 `Record`/ `Result` 的数据类型转换方法名称，原有的转换方法标记为 `deprecated`；
   - `Record`/ `Result` 查询结果类型增加 `IsEmpty` 方法，用于判断结果集是否为空；
   - `Record` 类型增加 `GMap` 方法，用于将查询记录转换为 `gmap` 类型；
   - 增加 `Option`/ `OptionOmitEmpty` 方法，用于输入参数过滤，包括 `Data` 参数及 `Where` 参数： [https://goframe.org/database/gdb/empty](https://wiki.goframe.org/database/gdb/empty)
   - 增加字段排除方法 `FieldsEx`： [https://goframe.org/database/gdb/senior](https://wiki.goframe.org/database/gdb/senior)
   - 增加日志功能特性： [https://goframe.org/database/gdb/senior](https://wiki.goframe.org/database/gdb/senior)
   - 改进数据库配置管理： [https://goframe.org/database/gdb/config](https://wiki.goframe.org/database/gdb/config)
   - 增加大量单元测试；
2. `gredis`
   - 返回数据类型转换改进： [https://github.com/gogf/gf/issues/415](https://github.com/gogf/gf/issues/415)
   - 完善单元测试；
   - 其他改进；

#### `os`

1. `gcache`
   - 需要注意了：缓存的有效时间参数从 `interface{}` 类型调整为了 `time.Duration` 类型，因此不再兼容之前的 `int` 参数类型，以保证更好的性能；
2. `gfcache`
   - 由于 `gcache` 组件的缓存时间参数类型的变更，因此该组件的时间参数也变更为了 `time.Duration` 类型；
3. `gcfg`
   - 增加 `Available` 方法，用以判断配置是否有效；
4. `gfile`
   - 增加 `Chdir` 方法，用于工作目录切换；
5. `gtime`
   - 增加 `JSON` 数据格式的 `Marshal`/ `UnMarshal` 接口实现；

#### `container`

1. `gmap`
   - 增加 `MapStrAny` 方法，用于常见 `map` 类型的转换；
   - 增加 `MapCopy` 方法，用于底层 `map` 数据复制；
   - 增加 `FilterEmpty` 方法，用于 `map` 空值过滤；
   - 增加 `Pop`/ `Pops` 方法，用于随机返回 `map` 中的数据项（并删除）；
   - 增加 `Replace` 方法，用于给定的 `map` 数据覆盖底层 `map` 数据项；
   - 完善单元测试；
   - 其他改进；
2. `garray`
   - 增加 `Interfaces` 转换方法，返回 `[]interface{}` 类型；
   - 对排序数组增加 `SetComparator` 方法用户自定义修改比较器；
   - 完善单元测试；
   - 其他改进；
3. `glist`
   - 增加 `NewFrom` 方法，基于给定的 `[]interface{}` 变量创建链表；
   - 增加 `Join` 方法，用于将链表项使用给定字符串连接为字符串返回；
   - 完善单元测试；
   - 其他改进；
4. `gset`
   - 增加 `AddIfNotExistFunc`/ `AddIfNotExistFuncLock` 方法；
   - 完善单元测试；
   - 其他改进；
5. `gtree`
   - 增加 `Replace` 方法，用于更新现有树的数据项；
   - 其他改进；
6. `gtype`
   - 一些细节改进工作，不一一列出；
   - 完善基准测试、单元测试；
7. `gvar`
   - 增加 `Ints`/ `Uints` 类型转换方法；
   - 其他改进；

#### `crypto`

1. `gmd5`
   - 小细节改进；
2. `gsha1`
   - 小细节改进；

#### `text`

1. `gstr`
   - 改进 `SplitAndTrim` 方法，将 `SplitAndTrimSpace` 标记为 `deprecated`；
   - 增加 `TrimStr` 方法；
   - 完善单元测试；
   - 其他改进；

#### `debug`

1. `gdebug`
   - 增加 `CallerFileLineShort`/ `FuncPath`/ `FuncName` 方法；
   - 其他改进；

#### `encoding`

1. `gbase64`
   - 增加 `EncodeToString`/ `EncodeFile`/ `EncodeFileToString`/ `DecodeToString` 方法；
   - 完善单元测试；
2. `gjson`
   - 完善单元测试；

#### `frame`

1. `g`/ `gins`
   - [https://goframe.org/frame/g/index](https://wiki.goframe.org/frame/g/index)
   - 增加 `CreateVar` 方法；
   - 完善单元测试；
   - 其他改进；

#### `util`

1. `gconv`
   - 改进优化部分类型转换方法性能；
   - 增加 `Uints`/ `SliceUint` 类型转换方法；
   - 增加 `UnsafeStrToBytes`/ `UnsafeBytesToStr` 高性能的类型转换方法；
   - 增加对 `MapStrAny` 接口方法的支持，用于常见 `map` 类型的转换；
   - 其他改进；
2. `gvalid`
   - 改进对中国身份证号的识别校验功能；
   - 增加 `luhn` 银行卡号的校验功能；
3. `grand`
   - 一些性能改进工作；

### Bug Fix

1. 解决 `WebSocket` 关闭时的 `hijacked` 报错问题： [https://github.com/gogf/gf/issues/381](https://github.com/gogf/gf/issues/381)
2. 解决静态文件服务时大文件的内存占用问题；
3. 修复前置 `Nginx` 后默认情况下的 `Cookie` 域名设置问题；
4. 修复 `gconv.Struct` 在属性为 `[]struct` 并且输入属性参数为空时的转换失败问题： [https://github.com/gogf/gf/issues/405](https://github.com/gogf/gf/issues/405)
5. 其他一些修复；
