Golang
📌 Go-Slice-切片操作汇总
· ☕ 5 分钟
Go Slice 切片核心机制与扩容策略:slice header 三元组、共享底层数组、append 扩容两把尺子(需求大小 + 切片大小)、Go 1.18 平滑过渡公式、内存对齐、常见陷阱

Go-fmt格式化IO
· ☕ 2 分钟
重要 fmt 是 Go 中使用频率最高的包之一。日常开发中,三个动词覆盖 90% 场景:%v(默认格式)、%+v(带字段名)、%#v(Go 语法表示)。 环境说明 Go

Go-Defer说明
· ☕ 3 分钟
重要 defer语句是Go中一个非常有用的特性,可以将一个方法延迟到包裹defer的方法返回时执行,在实际应用中,defer可以充当其他语言中

Go-Path-文件路径操作汇总
· ☕ 5 分钟
重要 1. 目录操作 1.1 删除目录 删除目录下所有内容 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 // Golang program to illustrate how to // remove all the files and directories // from the default directory package main import ( "log" "os" ) func main() { //

Go-Strings-字符串操作汇总
· ☕ 13 分钟
字符串常见操作有: 字符串长度; 求子串; 是否存在某个字符或子串; 子串出现的次数(字符串匹配); 字符串分割(切分)为[]string; 字符串是否

Go 常用函数备忘
· ☕ 1 分钟
重要 记录开发中常用的 Go 代码片段。 1. 字符串转 int64 1 2 3 4 5 6 7 var s string = "9223372036854775807" i, err := strconv.ParseInt(s, 10, 64) if err != nil { panic(err) } fmt.Printf("Hello, %v with type %s!\n", i, reflect.TypeOf(i)) // Hello, 9223372036854775807 with type int64! 2. 最小化 gormigrate 1 2 3 4 5