摘要: package main import ( "context" "log" ) // 需要处理的请求数据 type Request struct { Ctx context.Context Id int } // 定义处理器接口 type Handler interface { Process(re 阅读全文
posted @ 2025-04-17 16:20 cn_zt 阅读(23) 评论(0) 推荐(0)
摘要: Go项目实战—RabbitMq篇 技术栈 gin gorm rabbitmq 数据库表结构: CREATE TABLE `article` ( `id` int NOT NULL AUTO_INCREMENT, `article_name` varchar(64) COLLATE utf8mb4_unicode_ci NOT NUL 阅读全文
posted @ 2024-07-09 12:00 cn_zt 阅读(159) 评论(0) 推荐(0)
摘要: Go中singleflight文件提供了可重复的函数调用抑制机制。通过给每次函数调用分配一个key,相同key的函数并发调用时,只会被执行一次,返回相同的结果。其本质是对函数调用的结果进行复用。一般用于缓存击穿,去除重复请求 阅读全文
posted @ 2023-12-11 22:09 cn_zt 阅读(61) 评论(0) 推荐(0)
摘要: 判断是否成环 slow , fast := head, head for fast != nil && fast.Next != nil{ if fast == slow { return true } fast = fast.Next.Next slow = slow.Next } return 阅读全文
posted @ 2023-12-04 16:18 cn_zt 阅读(15) 评论(0) 推荐(0)