serialt published on included in Go go sync 包 1、sync.WaitGroup(等待组) 用途:等待一组 Goroutine 全部执行完成。常用于主程序等待后台任务结束,或者在批量处理任务时确保所有子任
serialt published on included in Go BufBuild https://buf.build/docs/cli/installation/#homebrew syntax = "proto3"; package example; import "google/api/annotations.proto"; import "google/protobuf/empty.proto"; message GetUserRequest { string id = 1; } message User { string id = 1; string name = 2; } service UserService { // 定义 HTTP 映射: GET /v1/users/{id} rpc GetUser(GetUserRequest) returns (User) { option (google.api.http) = { get: "/v1/users/{id}" }; // 用于 Swagger 文档的描述 option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { summary: &
serialt published on included in Go Go Redis 使用 一、Redis数据结构和一些特性介绍 1、基本数据类型 字符串 string 列表 list 哈希 hash 集合 set 有序集合 sorted set 2、其他比较高级的数据结构 HyperLogLog 基数统计算法 Geospatial
serialt published on included in Go kube-operator开发示例 使用 Kubebuilder 开发 Kubernetes Operator 是目前 Go 语言生态中最主流、最高效的方式。它是 Kubernetes 官方推荐的 SDK,基于 controller-runtime 和 controller-tools 构建,能自动生成 boilerplate
serialt published on included in Go Go Kratos测试 1、测试repo层方法 glogger "gorm.io/gorm/logger" "github.com/go-kratos/kratos/v2/log" var ( msg = "hello" ctx = context.Context db *gorm.DB p = NewSugarRepo(log.DefaultLogger) bc conf.Bootstrap ) func init() { bcInit() var err error var dns = bc.Data.Database.Source db, err = gorm.Open(postgres.Open(dns), &gorm.Config{ Logger: glogger.Default.LogMode(glogger.Info), }) if err != nil { panic(err) } md := metadata.New(map[string]string{ "message": msg,
serialt published on included in Go Gock: 开发项目的过程中总会遇到要调用依赖方接口的情况,如果依赖方的API接口还没有开发好,通常我们会先约定好API接口的请求参数、响应结构和各