![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
go
文章平均质量分 76
offhours365
个人网站:http://www.offhours365.com/
展开
-
go database/sql 库 连接池管理
1.了解DB结构体里的有关连接数变量 type DB struct { ..... freeConn []*driverConn //空闲连接队列 connRequests map[uint64]chan connRequest //正在阻塞的sql请求,等有空闲连接来处理 numOpen int //程序内已开启和正在开启的连接数 maxIdle int //连接池内空闲连接的最大个数 maxOpen int //连接池内最大可以开原创 2021-03-20 00:49:06 · 763 阅读 · 2 评论 -
时区+0800 CST 与+0805 LMT转换
1、+0800 CST 与+0805 LMT区别 大多数计算机保留的有关时区的数据来自IANA时区数据库(Time Zone Database, TZDB)。TZDB 中"Asia/Shanghai"的时区偏移 不止 +08:00 一个,在 1850-1900 年,偏移量为 +08:05:43,1901年以及后,偏移量才是 +08:00。所以时区+0800 CST 与+0805 LMT都是中国时区,不过对应的是不同的阶段。 更详细的就是以LMT时间1901年,也就是UTC时间1...原创 2021-03-06 16:50:58 · 4640 阅读 · 0 评论 -
grpc-gateway转化grpc与http api规则
1、介绍 gRPC Transcoding 是一种定义了grpc与http rest api转化规则,这种规则适用于 Google APIs, Cloud Endpoints, gRPC Gateway等,目前已被广泛使用。 英文文档见: https://cloud.google.com/endpoints/docs/grpc-service-config/reference/rpc/google.api#google.api.HttpRule 代码可见: https://github.com/g原创 2021-02-09 15:54:01 · 2383 阅读 · 0 评论 -
protobuf 自定义extend
1、proto2 extension proto2 extensions 官网指导说明: https://developers.google.com/protocol-buffers/docs/proto#extensions 定义: https://github.com/golang/protobuf/blob/4846b58453b3708320bdb524f25cc5a1d9cda4d4/internal/testprotos/proto2_proto/test.proto#L266 使用.原创 2021-01-12 20:07:10 · 2985 阅读 · 0 评论 -
go函数值传递
func testarr(a []int) { a = []int{1} } func testint(a int) { a = 1 } func testarrptr(a *[]int) { b := []int{1} a = &b } func testintptr(a *int) { b := 1 a = &b } func testarrptrval(a *[]int) { b := []int{1} *a =.原创 2020-12-15 11:57:26 · 95 阅读 · 0 评论 -
go reflect 与slice
1. slice slice底层存储的其实一个结构,如下: type slice struct { array unsafe.Pointer len int cap int } 先提供一篇文章加深理解slice对象的文章: https://segmentfault.com/a/1190000017910165?utm_source=sf-related 以下我用go1.13.8 linux/amd64,再次测试: func testsl原创 2020-12-02 10:17:09 · 1495 阅读 · 0 评论 -
通过反射深入学习go接口
1. 常见的interface用法 1.1 作为方法的集合,提供方法 type Animal interface { Eat() } type Dog struct {} func (d *Dog) Eat() { fmt.Println("Dog eat") } var ani Animal ani = &Dog{} ani.Eat() //output: "Dog eat" 1.2 作为类型容器,接受和转换各种基础类型 var a interface{} nu.原创 2020-12-02 09:55:39 · 91 阅读 · 0 评论