Go 1.13版本引入的bug,你遇到过这个坑么? 2022-05-14 go bug 996 words 2 mins read Bug 大家看看下面这段程序,思考下输出结果应该是什么? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 func main() { n := 0 f := func() func(int, int) { n = 1 return func(int, int) {} } g := func() (int, int) { println(n) return 0, 0 } Read more...
Go Quiz: 从Go面试题看变量的零值和初始化赋值的注意事项 2022-05-05 go quiz zero-value 零值 1207 words 3 mins read 背景 Google工程师Valentin Deleplace出了1道关于变量初始化的题目,本来以为很简单,没想到回答正确率不到30%,拿出来和大 Read more...
Go并发编程之原子操作sync/atomic 2022-05-04 go sync atomic value 3630 words 8 mins read sync/atomic定义 官方文档地址:https://pkg.go.dev/sync/atomic@go1.18.1 Go语言标准库中的sy Read more...
Go 1.18版本iota的bug 2022-05-03 go1.18 iota bug 1289 words 3 mins read Iota iota是Go语言的预声明标识符,用于常量的声明。 iota的值是const语句块里的行索引,值从0开始,每次递增加1。通过下面的代码示例我 Read more...
泛型最佳实践:Go泛型设计者教你如何用泛型 2022-04-22 go1.18 generics 泛型 4168 words 9 mins read 前言 Go泛型的设计者Ian Lance Taylor在官方博客网站上发表了一篇文章when to use generics,详细说明了在什么场景下应该使用泛型,什么 Read more...