我的 Go 语言学习之路

以下内容是我在 Tony Bai · Go 语言第一课的分享用户故事|罗杰:我的Go语言学习之路 你好,我是罗杰,目前在一家游戏公司担任后端开发主程。今天,我想跟你分享一下我学习Go的一些经历,如果你还是一个Go新人,希望我的这些经历,能给你带来一些启发和帮助。 说起来,我接触Go语言已经很久了,但前面好多次都没真正学起来。 我第一次接触 Go 语言是在 2010 年,当时我还在读大二,一个学长建议我了解一下 Go 语言,毕竟是谷歌出的一门语言,可能未来比较有发展前景。所以我当时下载并安装了Go的开发环境,还写了个 “hello world”,但是由于没有中文的教程,也没有人一起学习,学习 Go 语言这件事情很快就被我抛在脑后了。 ...

2021-12-27 · 17 分钟 · 约 9718 字

除 0 真的会 panic 吗?

某天,小伙伴反馈说程序 panic 在一个比较诡异的地方,差不多是下面的代码。 type Point struct { X float32 Y float32 } func Get(p Point) { // import github.com/shopspring/decimal x, _ := decimal.NewFromFloat32(p.X).Round(7).Float64() } ...

2021-10-16 · 6 分钟 · 约 1860 字

如何删除 MySQL 表中 2.5 亿条数据?

为什么会有 2.5 亿条数据 运营需求,需要提供查询用户登录的记录。 我一思索,这简单呀,就设计了如下的数据表。 desc login_record; +-------------+------------------+------+-----+-------------------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+------------------+------+-----+-------------------+-------+ | user_id | int(10) unsigned | NO | MUL | NULL | | | ip | varchar(40) | YES | | | | | device_mark | varchar(500) | NO | | | | | time | timestamp | NO | MUL | CURRENT_TIMESTAMP | | +-------------+------------------+------+-----+-------------------+-------+ ...

2021-05-25 · 5 分钟 · 约 2659 字

Go 中"坑爹"的类型转换

go 代码 package main import ( "fmt" "math" ) func main() { var count uint32 fmt.Printf("count: %d\n", count) fmt.Printf("count - 1: %d\n", count - 1) // num := math.Pow(2, float64(count-1)) fmt.Printf("math.Pow(2, float64(count-1)): %f\n", math.Pow(2, float64(count-1))) fmt.Printf("int(math.Pow(2, float64(count-1))): %d\n", int(math.Pow(2, float64(count-1)))) fmt.Printf("uint32(math.Pow(2, float64(count-1))): %d\n", uint32(math.Pow(2, float64(count-1)))) fmt.Printf("int32(math.Pow(2, float64(count-1))): %d\n", int32(math.Pow(2, float64(count-1)))) fmt.Printf("uint64(math.Pow(2, float64(count-1))): %d\n", uint64(math.Pow(2, float64(count-1)))) fmt.Printf("int64(pow(2,1023): %d\n", int64(math.Pow(2, 1023))) fmt.Printf("uint64(pow(2,1023): %d\n", uint64(math.Pow(2, 1023))) } ...

2020-09-20 · 4 分钟 · 约 1772 字