3yfist 梦虽遥,追则能达;愿虽艰,持则可圆 ✊✊✊

nsq通关秘籍(二) - nsq在go中使用

nsq通关秘籍(二) - nsq在go中使用 官方 Go 客户端包 go get github.com/nsqio/go-nsq 发布 producer, _ := nsq.NewProducer("localhost:4150", nsq.NewConfig()) _ = producer.Pu

chiachan Published on 2025-04-21

nsq通关秘籍(一) - 初识nsq

nsq通关秘籍 - 初识nsq NSQ 简介 NSQ 是一个实时分布式消息平台,具有高可用、高性能、易部署、无单点依赖等特点。 适用于解耦系统中的模块通信,如异步任务、事件分发、数据流处理等。 核心组件 1. nsqd 负责接收、排队、投递消息 每条消息只能被一个 Channel 中的一个消费者消费

chiachan Published on 2025-04-21

gocv的yolo-detection代码分析

https://github.com/hybridgroup/gocv/tree/release/cmd/yolo-detection 文件分析及关键函数注释 文件概述 该文件实现了使用YOLOv8深度神经网络进行对象检测的功能。它从指定的视频源(摄像头或视频文件)读取帧,并使用预训练的YOLOv8

chiachan Published on 2025-02-07

go语言学习笔记 - channal实战

Worker 池并发任务处理器 package main import ( "fmt" "sync" "time" ) type Task struct { ID int } func (t Task) Do() { fmt.Printf("任务 %d

chiachan Published on 2025-01-22

go语言学习笔记 - channal

Go语言笔记 - Channel 1. 什么是channel Channel 是 Go 语言中用来在 goroutine 之间传递数据的通信机制,本质上像一个管道(队列),可以安全地在线程之间传数据,避免加锁。 通俗点说,Channel 就是 goroutine 之间用来**发送(send)和接收(

chiachan Published on 2025-01-19

对kratos服务进行颜色标签过滤

解决如何对kratos服务进行颜色标签过滤 应用场景 生产环境下新功能测试 带标签状态的需求 对来源用户进行分类服务划分 给服务打上color标签 在main.go中,metadata加入color标签即可,可以参考一下方式。从启动命令中读取 ... func init() { flag.Stri

chiachan Published on 2025-01-09

谜题排查:concurrent map read and map write报错

问题 今天收到同事发来的报错concurrent map read and map write 报错位置源码如下: var data = make(map[string]int64, 100) func GetValue(name string) int64 { return data[name

chiachan Published on 2025-01-09

go语言的Mutex和RWMutex

golang 中的 sync 包实现了两种锁: Mutex:互斥锁 RWMutex:读写锁,RWMutex 基于 Mutex 实现 Mutex(互斥锁) Mutex 为互斥锁,Lock() 加锁,Unlock() 解锁 在一个 goroutine 获得 Mutex 后,其他 goroutine 只能

chiachan Published on 2025-01-09

聊聊go语言的测试

聊聊go语言的测试 Test 测逻辑,Benchmark 测性能,Example 做文档,表格测试是王道,Mock 让你上天跑! Go 测试类型 类型 说明 文件名 函数前缀 单元测试 测函数/方法的行为是否正确 xxx_test.go TestXxx(t *testing.T) 基准测试 测函数性

chiachan Published on 2025-01-08

go语言学习笔记 - 数组与切片

go语言学习笔记 - 数组与切片 数组(Array)是定长的值类型。是一段连续的内容 切片(Slice)是动态的引用类型。是一个结构体 数组(Array) var arr [3]int = [3]int{1, 2, 3} 特点: 固定长度:[3]int 是一个长度为 3 的数组类型。 值类型:传参

chiachan Published on 2025-01-06
Previous Next