undefined

一、runtime.Gosched 函数解析

作用:让当前 goroutine 让出 CPU,好让其他的 goroutine 获得执行的机会。同时,当时的 goroutine 也会在未来的某个时间点继续运行

1
runtime.Gosched()

二、获取Go程序的汇编代码

1
2
3
4
5
6
7
8
9
1. 使用 go tool compile 生成汇编代码
go tool compile -N -l -S xxx.go

2. 使用 go tool objdump
首先编译程序:go tool compile -N -l xxx.go
使用 go tool objdump xxx.go 反汇编出代码;或者使用 go tool objdump -s Do xxx.go 反汇编特定的函数

3. 使用 go build -gcflags -S
go build -gcflags -S xxx.go 得到汇编代码