随笔 - 231  文章 - 205  评论 - 20  阅读 - 41万
12 2022 档案
golang中使用原子操作监听配置更新
摘要:配置及代码文件 { "name":"sasuke", "age":25, "gender":"male", "score":99.5 } develop.json package main import ( "crypto/md5" "encoding/hex" "encoding/json" "f 阅读全文
posted @ 2022-12-29 16:45 江湖乄夜雨 阅读(142) 评论(0) 推荐(0) 编辑
golang中goroutine泄漏的问题以及解决方案
摘要:参考文章 Goroutine leak Golang中的goroutine泄漏问题 如何退出协程 goroutine (超时场景) 如何退出协程 goroutine (其他场景) 问题纠正 之前视频讲过一个知识点,如何设置子协裎超时机制,其实像下面这段代码,主协裎关闭后子协裎是不会停止的: func 阅读全文
posted @ 2022-12-25 10:51 江湖乄夜雨 阅读(704) 评论(0) 推荐(0) 编辑
golang实现等待通知机制的方法
摘要:参考博客: https://geektutu.com/post/hpg-sync-cond.html https://cyent.github.io/golang/goroutine/sync_cond/ 使用sync.Cond实现 如果想在使用 Cond 的时候避免犯错,只要时刻记住**调用 co 阅读全文
posted @ 2022-12-18 10:23 江湖乄夜雨 阅读(634) 评论(0) 推荐(0) 编辑
使用errgroup并发查询数据库
摘要:参考文章 [Golang]并发编程包之errgroup —— 文中最后那个ctx的坑注意一下! errgroup使用方法及适用场景 代码演示 package aerrgrouptests import ( "context" "fmt" "sort" "sync" "testing" "github 阅读全文
posted @ 2022-12-13 20:34 江湖乄夜雨 阅读(157) 评论(0) 推荐(0) 编辑
sync.Once的基本使用以及拓展
摘要:基本的单例模式 之前总结过博客:https://www.cnblogs.com/paulwhw/p/15450657.html#_label2 看一下Once的源码 type Once struct { done uint32 m Mutex } func (o *Once) Do(f func() 阅读全文
posted @ 2022-12-10 13:12 江湖乄夜雨 阅读(142) 评论(0) 推荐(0) 编辑
使用channel控制并发数
摘要:不带超时的写法 package concurrent_test import ( "fmt" "math/rand" "sync" "testing" "time" ) func init() { rand.Seed(time.Now().UnixNano()) } // 使用channel控制并发 阅读全文
posted @ 2022-12-06 16:46 江湖乄夜雨 阅读(195) 评论(0) 推荐(0) 编辑
gorm更新数据遇到的空值问题
摘要:package gorm_tests import ( "fmt" "github.com/fatih/structs" "github.com/go-playground/validator/v10" "github.com/stretchr/testify/require" "gorm.io/d 阅读全文
posted @ 2022-12-02 19:55 江湖乄夜雨 阅读(1365) 评论(0) 推荐(0) 编辑
golang校验结构体字段的库validator的使用
摘要:package scripts_stroage import ( "fmt" "github.com/go-playground/validator/v10" "testing" ) // 参考博客: // https://juejin.cn/post/6900375680358285325 // 阅读全文
posted @ 2022-12-02 15:56 江湖乄夜雨 阅读(221) 评论(0) 推荐(0) 编辑

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示