上一页 1 2 3 4 5 6 7 8 9 ··· 23 下一页
  2023年2月2日
摘要: 项目地址 项目地址:https://gitee.com/huoyingwhw/kratos-gorm-transaction 功能介绍 事务开始时使用tx 事务的2种使用方法: 一种是在biz层使用事务然后data层的方法使用DB(ctx)获取tx;另外一种是将事务的操作都放到data层 使用依赖注 阅读全文
posted @ 2023-02-02 19:17 江湖乄夜雨 阅读(315) 评论(0) 推荐(0) 编辑
  2023年1月26日
摘要: wrk压测的lua脚本里面的参数使用随机列表与随机字符串 压测: wrk压测的lua脚本使用随机列表与字符串参数 wrk 我自己的B站文章地址 https://www.bilibili.com/read/cv20239103?spm_id_from=333.999.list.card_article 阅读全文
posted @ 2023-01-26 16:12 江湖乄夜雨 阅读(40) 评论(0) 推荐(0) 编辑
  2023年1月13日
摘要: 单机程序加锁的场景以及sync.Mutex介绍 简单的并发问题以及解决方案 在单机程序并发或并行修改全局变量时,需要对修改行为加锁以创造临界区。看一下下面的例子: type Counter struct { count int } func (c *Counter) incr() { c.count 阅读全文
posted @ 2023-01-13 14:21 江湖乄夜雨 阅读(372) 评论(0) 推荐(0) 编辑
  2022年12月29日
摘要: 配置及代码文件 { "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 江湖乄夜雨 阅读(129) 评论(0) 推荐(0) 编辑
  2022年12月25日
摘要: 参考文章 Goroutine leak Golang中的goroutine泄漏问题 如何退出协程 goroutine (超时场景) 如何退出协程 goroutine (其他场景) 问题纠正 之前视频讲过一个知识点,如何设置子协裎超时机制,其实像下面这段代码,主协裎关闭后子协裎是不会停止的: func 阅读全文
posted @ 2022-12-25 10:51 江湖乄夜雨 阅读(580) 评论(0) 推荐(0) 编辑
  2022年12月18日
摘要: 参考博客: 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 江湖乄夜雨 阅读(571) 评论(0) 推荐(0) 编辑
  2022年12月13日
摘要: 参考文章 [Golang]并发编程包之errgroup —— 文中最后那个ctx的坑注意一下! errgroup使用方法及适用场景 代码演示 package aerrgrouptests import ( "context" "fmt" "sort" "sync" "testing" "github 阅读全文
posted @ 2022-12-13 20:34 江湖乄夜雨 阅读(144) 评论(0) 推荐(0) 编辑
  2022年12月10日
摘要: 基本的单例模式 之前总结过博客: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 江湖乄夜雨 阅读(121) 评论(0) 推荐(0) 编辑
  2022年12月6日
摘要: 不带超时的写法 package concurrent_test import ( "fmt" "math/rand" "sync" "testing" "time" ) func init() { rand.Seed(time.Now().UnixNano()) } // 使用channel控制并发 阅读全文
posted @ 2022-12-06 16:46 江湖乄夜雨 阅读(158) 评论(0) 推荐(0) 编辑
  2022年12月2日
摘要: 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 江湖乄夜雨 阅读(1151) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 ··· 23 下一页