随笔分类 - golang
摘要:https://go.dev/doc/faq#atomic_maps
阅读全文
摘要:https://mp.weixin.qq.com/s/i2jA817fXK7TxyA3lLP22A nil 接口不是 nil 我们强行将一段 Go 程序的变量值赋为 nil,并进行 nil 与 nil 的判断。 代码如下: func main() { var v interface{} v = (*
阅读全文
摘要:小结: 1、 type Any interface { } v1 := new(Any) err = json.Unmarshal([]byte(bs1), &v1) V interface{} resp.V = v1 package presentationLayer import ( "Test
阅读全文
摘要:实践: 1、 import "encoding/json" func mapVstruct2jsonMarshal() { t := struct { A string B int32 C bool }{"a", 123, true} m := map[string]interface{}{ "A"
阅读全文
摘要:int-->string strconv.Itoa(i) []byte-->string ...
阅读全文
摘要:https://mp.weixin.qq.com/s/ddpi0r3Q5uonLljX1dtq2g
阅读全文
摘要:Go 高性能编程技法 - 知乎 https://zhuanlan.zhihu.com/p/482547957 1.1 优先使用 strconv 而不是 fmt 基本数据类型与字符串之间的转换,优先使用 strconv 而不是 fmt,因为前者性能更佳。 // Bad for i := 0; i <
阅读全文
摘要:// Keep the fibbers in dedicated operating system // threads, so that this program tests coordination // between pthreads and not just goroutines. run
阅读全文
摘要:go内存地址 - 简书 https://www.jianshu.com/p/c4dd003b48d7 the-way-to-go_ZH_CN/10.2.md at master · unknwon/the-way-to-go_ZH_CN · GitHub https://github.com/unk
阅读全文
摘要:the-way-to-go_ZH_CN/10.1.md at master · unknwon/the-way-to-go_ZH_CN · GitHub https://github.com/unknwon/the-way-to-go_ZH_CN/blob/master/eBook/10.1.md
阅读全文
摘要:小结: 1、 t1 := T{} var t5 T t5 = T{} t2 := new(T) var t3 *T = new(T) var t4 *T t4 = new(T) t6 := &T0{} var t7 *T0 t7 = &T0{} t1 t5 : 结构体类型变量给 t 分配内存,并零值
阅读全文
摘要:小结: 1、结构体、指针是否相等 https://go.dev/ref/spec#Comparison_operators Comparison operators Comparison operators compare two operands and yield an untyped bool
阅读全文
摘要:golang本地缓存(bigcache/freecache/fastcache等)选型对比及原理总结 - 知乎 https://zhuanlan.zhihu.com/p/487455942 golang本地缓存(bigcache/freecache/fastcache等)选型对比及原理总结 目录
阅读全文
摘要:小结: 1、 1.上述本地缓存组件中,实现零 GC 的方案主要就两种:a.无 GC:分配堆外内存(Mmap)b.避免 GC:map 非指针优化(map[uint64]uint32)或者采用 slice 实现一套无指针的 mapc.避免 GC:数据存入[]byte slice(可考虑底层采用环形队列封
阅读全文
摘要:源码 json.Unmarshal json.Marshal
阅读全文
摘要:s := "24" b := "1245" fmt.Println(b[1:3]) fmt.Println(s == "24") fmt.Println(s > "23") fmt.Println(s < "22")
阅读全文
摘要:Golang在商业化广告的优化实践 https://mp.weixin.qq.com/s/joR1Y5t4a8fIs111XNZluA
阅读全文
摘要:golang map源码分析 - 简书 https://www.jianshu.com/p/0d07eb2d3598
阅读全文