-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
115 changed files
with
198 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ hide_title: true | |
使用 `GoFrame` 框架是严谨和安全的,如果程序产生了异常,会默认被框架捕获。如果未被自动捕获,那么可能是由于程序逻辑自行开了新的 `goroutine`,在新的 `goroutine` 中产生了异常。因此这里有两个方案可供大家选择: | ||
|
||
- 不建议在请求中再开 `goroutine` 来处理请求,这样或使得 `goroutine` 快速膨胀,当 `goroutine` 多了之后也会在 `Go` 引擎层面影响程序的整体调度。 | ||
- 如果实在有必要新开 `goroutine` 的场景下,可以考虑使用 `grpool.AddWithRecover` 来创建新的 `goroutine`,见名知意,它会自动捕获异常。更详细的介绍请参考: [协程管理-grpool](/docs/组件列表/系统相关/协程管理-grpool) | ||
- 如果实在有必要新开 `goroutine` 的场景下,可以考虑使用 `grpool.AddWithRecover` 来创建新的 `goroutine`,见名知意,它会自动捕获异常。更详细的介绍请参考: [协程管理-grpool](5-组件列表/1-系统相关/16-协程管理-grpool.md) | ||
|
||
### 2、 `json` 输出时屏蔽掉一些字段 | ||
|
||
|
@@ -70,7 +70,7 @@ D:\Program Files\Go\bin\pkg\mod\github.com\gogf\[email protected]\net\ghttp\internal\cl | |
|
||
## 三、数据库相关 | ||
|
||
请参考章节: [ORM常见问题](/docs/核心组件/数据库ORM/ORM常见问题) | ||
请参考章节: [ORM常见问题](4-核心组件/10-数据库ORM/11-ORM常见问题.md) | ||
|
||
## 四、使用相关 | ||
|
||
|
@@ -79,7 +79,7 @@ D:\Program Files\Go\bin\pkg\mod\github.com\gogf\[email protected]\net\ghttp\internal\cl | |
不同环境指的是:开发环境/测试环境/预发环境/生产环境等。 | ||
|
||
- 首先,在一些互联网项目中,特别是分布式或者微服务化的架构下,一般会使用配置管理中心,不同的环境会对应不同的配置管理中心,所以这样的场景不会存在这样的问题。 | ||
- 其次,如果是传统的项目管理方式下,可能会将配置文件放到代码仓库中共同管理,这样的方式是不推荐的。如果您仍然想要这么做,您可以通过系统环境变量或者命令行启动参数,让程序自动选择配置文件或者指定配置目录,参考 [配置管理](/docs/核心组件/配置管理) 章节。例如: `./app --gf.gcfg.file config-prod.toml ` 则通过命令行启动参数的方式将默认读取的配置文件修改为了 `config-prod.toml` 文件。 | ||
- 其次,如果是传统的项目管理方式下,可能会将配置文件放到代码仓库中共同管理,这样的方式是不推荐的。如果您仍然想要这么做,您可以通过系统环境变量或者命令行启动参数,让程序自动选择配置文件或者指定配置目录,参考 [配置管理](4-核心组件/3-配置管理/3-配置管理.md) 章节。例如: `./app --gf.gcfg.file config-prod.toml ` 则通过命令行启动参数的方式将默认读取的配置文件修改为了 `config-prod.toml` 文件。 | ||
|
||
|
||
|
||
|
@@ -90,7 +90,7 @@ D:\Program Files\Go\bin\pkg\mod\github.com\gogf\[email protected]\net\ghttp\internal\cl | |
|
||
### 2、 `glog with "ERROR: logging before flag.Parse"` | ||
|
||
`Golang` 官方有个简单的日志库包名也叫做 `glog`,检查你文件顶部 `import` 的包名,将 `github.com/golang/glog` 修改为框架的日志组件即可,日志组件使用请参考: [日志组件](/docs/核心组件/日志组件) | ||
`Golang` 官方有个简单的日志库包名也叫做 `glog`,检查你文件顶部 `import` 的包名,将 `github.com/golang/glog` 修改为框架的日志组件即可,日志组件使用请参考: [日志组件](4-核心组件/4-日志组件/4-日志组件.md) | ||
|
||
### 3、 `gcron` 与 `http` 如何同时使用? | ||
|
||
|
@@ -122,21 +122,21 @@ func main() { | |
|
||
| Tag(简写) | 全称 | 描述 | 相关文档 | | ||
| --- | --- | --- | --- | | ||
| `v` | `valid` | 数据校验标签。 | [Struct校验-基本使用](/docs/核心组件/数据校验/数据校验-参数类型/数据校验-Struct校验/Struct校验-基本使用) | | ||
| `p` | `param` | 自定义请求参数匹配。 | [请求输入-对象处理](/docs/WEB服务开发/请求输入/请求输入-对象处理) | | ||
| `d` | `default` | 请求参数默认值绑定。 | [请求输入-默认值绑定](/docs/WEB服务开发/请求输入/请求输入-默认值绑定) | | ||
| `orm` | `orm` | ORM标签,用于指定表名、关联关系。 | [数据规范-gen dao](/docs/开发工具/代码生成-gen/数据规范-gen%20dao)<br />[模型关联-静态关联-With特性](/docs/核心组件/数据库ORM/ORM链式操作/ORM链式操作-模型关联/模型关联-静态关联-With特性) | | ||
| `v` | `valid` | 数据校验标签。 | [Struct校验-基本使用](4-核心组件/6-数据校验/3-数据校验-参数类型/1-数据校验-Struct校验/0-Struct校验-基本使用.md) | | ||
| `p` | `param` | 自定义请求参数匹配。 | [请求输入-对象处理](7-WEB服务开发/3-请求输入/1-请求输入-对象处理.md) | | ||
| `d` | `default` | 请求参数默认值绑定。 | [请求输入-默认值绑定](7-WEB服务开发/3-请求输入/4-请求输入-默认值绑定.md) | | ||
| `orm` | `orm` | ORM标签,用于指定表名、关联关系。 | [数据规范-gen dao](3-开发工具/5-代码生成-gen/1-数据规范-gen dao.md)<br />[模型关联-静态关联-With特性](4-核心组件/10-数据库ORM/1-ORM链式操作/4-ORM链式操作-模型关联/1-模型关联-静态关联-With特性.md) | | ||
| `dc` | `description` | 通用结构体属性描述,ORM和接口都用到。属于框架默认的属性描述标签。 | | | ||
|
||
其他: | ||
|
||
- 命令行结构化管理参数: [命令管理-结构化参数](/docs/核心组件/命令管理/命令管理-结构化参数) | ||
- 命令行结构化管理参数: [命令管理-结构化参数](4-核心组件/2-命令管理/4-命令管理-结构化参数.md) | ||
- 框架常用标签标签集中管理到了 `gtag` 组件下: [https://github.com/gogf/gf/blob/master/util/gtag/gtag.go](https://github.com/gogf/gf/blob/master/util/gtag/gtag.go) | ||
- 在接口文档章节,由于采用了标签形式生成 `OpenAPI` 文档,因此标签比较多,具体请参考章节: [接口文档](/docs/WEB服务开发/接口文档) | ||
- 在接口文档章节,由于采用了标签形式生成 `OpenAPI` 文档,因此标签比较多,具体请参考章节: [接口文档](7-WEB服务开发/2-接口文档/2-接口文档.md) | ||
|
||
### 5、 `HTTP Server` 出现 `context cancel` 报错 | ||
|
||
从框架 `v2.5` 版本开始,框架的 `HTTP Server` 的 `Request` 对象将会直接继承与标准库的 `http.Request` 对象,其中就包括其中的 `context` 上下文对象,具体请参考发布记录: [v2.5 2023-07-17](/docs/版本发布记录/v2.5%202023-07-17)。当客户端例如浏览器、 `HTTP Client` 取消请求时,服务端会接收到 `context cancel` 操作( `context.Done`),但是服务端并不会直接报出 `context cancel` 的错误。这种错误往往在业务逻辑调用了底层的数据库、消息组件等组件时,由这些组件识别到 `context cancel` 操作,将会停止执行并往上抛出 `context cancel` 错误提醒上层已经终止执行。 | ||
从框架 `v2.5` 版本开始,框架的 `HTTP Server` 的 `Request` 对象将会直接继承与标准库的 `http.Request` 对象,其中就包括其中的 `context` 上下文对象,具体请参考发布记录: [v2.5 2023-07-17](/docs/版本发布记录/v2.5%202023-07-17.md)。当客户端例如浏览器、 `HTTP Client` 取消请求时,服务端会接收到 `context cancel` 操作( `context.Done`),但是服务端并不会直接报出 `context cancel` 的错误。这种错误往往在业务逻辑调用了底层的数据库、消息组件等组件时,由这些组件识别到 `context cancel` 操作,将会停止执行并往上抛出 `context cancel` 错误提醒上层已经终止执行。 | ||
|
||
这是符合标准库设计的行为,客户端终止请求后,服务端也没有继续执行下去的必要。 | ||
|
||
|
@@ -161,7 +161,7 @@ export GOPROXY=https://goproxy.cn | |
|
||
具体请看: | ||
|
||
- [Go Module](/docs/项目开发/准备工作/Go%20Module) | ||
- [Go Module](16-其他资料/0-准备工作/1-Go Module.md) | ||
- [https://goproxy.cn](https://goproxy.cn) | ||
|
||
### 2、 `Linux` 下安装 `gf` 提示命令不存在 `command not found` | ||
|
@@ -192,4 +192,4 @@ Build Time: 2021-03-30 15:43:22 | |
|
||
### 3、 `Win10` 提示 `gf` 命令不存在 | ||
|
||
解决办法:安装 `gf.exe` 参考: [开发工具](/docs/开发工具) | ||
解决办法:安装 `gf.exe` 参考: [开发工具](3-开发工具/3-开发工具.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.