随笔分类 - 源码学习
摘要:## go map 源码阅读 * 内存布局:golang中的map是怎么组成的 * 初始化 * 设置map值 * 获取map值 * 迭代map * 为什么迭代顺序每次都不一样 * 扩容 * 什么时候才会扩容 * 为什么是渐进式扩容 #### 源码地址 **src/runtime/map.go** #
阅读全文
摘要:# go 使用 unsafe 包进行指针操作 go 语言中没有直接提供指针操作,但是提供了 `unsafe` 包可以对指针进行转换 ```go // - A pointer value of any type can be converted to a Pointer. // - A Pointer
阅读全文
摘要:### 起因 在看 go 源码的时候,看到新包 `debug/elf` 包,手动进行尝试解析编译的二进制 写了一个demo ```golang func TestElf2(t *testing.T) { f, err := os.Open("testdata/binary") // 一个在mac系统
阅读全文
摘要:### 如何确定N的循环次数 不变量:时间,一般为1s,可以外部运行时指定 关键代码 ```go func (b *B) launch() { // Signal that we're done whether we return normally // or by FailNow's runtim
阅读全文