链式构建 mongodb 聚合查询语句 package builderimport "go.mongodb.org/mongo-driver/bson"type AggregateM []bson.Mtype AggregatePipe struct {agg AggregateM}// 用于调试时直接数据构建原始语句func (pipe *Aggr Golang 2020/11/29
nsq 在 golang 中使用 nsqlookupdhttps://nsq.io/components/nsqlookupd.htmlnsqlookupd 是管理拓扑信息的守护程序。客户端通过查询 nsqlookupd 以发现指定 topic 的 nsqd 生产者,并且 nsqd 节点广播 topic 和 channel。命令参数# lookupd 节点的外部地址,默认为主机名-broadcast-address=<host># 配置文件路径-config=<pa Golang 2020/07/01
grpc 在 golang 使用 Protocol Buffers1.安装编译器https://github.com/protocolbuffers/protobuf/releases 或者sudo apt -y install protobuf-compiler2.安装 go 插件go get -u github.com/golang/protobuf/protoc-gen-go3.编写 protohttps://developers.google Golang 2020/06/22
golang init 与 sync.Once 区别 sync.Once 是在代码运行中需要的时候执行,且只执行一次。init 函数是在文件包首次被加载的时候执行,且只执行一次。一个包中可以有多个 init 函数。init 函数不能被其它函数调用。const、var、 init 函数与 main 函数的执行顺序:验证代码package mainimport ( "fmt" "sync" Golang 2020/06/20
golang 实现的快速排序 package mainimport ( "fmt" "math/rand" "sort" "time")// func partition(arr Golang 2020/05/23
golang 解析腾讯视频真实链接 本文最后更新于 2020/05/01 18:22:37 。package mainimport ( "fmt" "io/ioutil" "net/http" "regexp" "string Golang 2020/04/07
golang rpc demo 本文最后更新于 2020/07/11 10:27:26 。客户端调用服务端server.gopackage mainimport ( "log" "net" "net/http" "net/rpc" Golang 2020/01/14
golang 反射的使用 package mainimport ( "fmt" "go/ast" "reflect")type Member struct { Id &nbs Golang 2020/01/04
注意 io.MultiWriter 的返回值 本文最后更新于 2020/07/04 01:58:54 。io.MultiWriter() 可以将多个实现 io.Writer 接口实例包装为一个,实现多实例统一写入。但在开发自定义日志库时使用此函数遇到了这样一个问提,传入的多个接口实例总会有几个不会生效,而且好似是否生效还跟入传参位置有关。 Golang 2019/12/25
golang 模板语法 测试用的变量和方法type struct Blog { Title string}map[string]interface{}type FuncMap map[string]interface{}func add(x, y int) int变量{{/* . 代表传入模板的 struct&nb Golang 2019/12/08