摘要: 背景 很多语言java php 等异常可以打印出异常的具体的信息 堆栈 文件行号 异常原因 但是golang 需要自己去不是方便 是不是也可以做到 行号 具体的信息呢 答案是可以的 查阅 golang 提供单个API debug.Stack() fmt.Errorf struct 实现 func E 阅读全文
posted @ 2022-04-13 14:07 vx_guanchaoguo0 阅读(29) 评论(0) 推荐(0) 编辑
摘要: 背景 需要并发的处理的任务 查阅 使用 waitgroup chan 代码实现 package main import ( "fmt" "sync" ) func main() { var l []int receive := func(w chan int, wg *sync.WaitGroup) 阅读全文
posted @ 2022-04-13 13:52 vx_guanchaoguo0 阅读(55) 评论(0) 推荐(0) 编辑
摘要: 背景记录 api 的返回值到日志 方便排查问题 查阅文档 使用Gin 提供方的中间件可以处理 点击查看代码 package main import ( "fmt" "math" ) const abortIndex int8 = math.MaxInt8 / 2 type Context struc 阅读全文
posted @ 2022-04-13 13:46 vx_guanchaoguo0 阅读(48) 评论(0) 推荐(0) 编辑