在线调试
(dlv) grs * Goroutine 1 - User: ./main.go:7 main.main (0x10aba6f) (thread 218565) Goroutine 2 - User: /usr/local/opt/go/libexec/src/runtime/proc.go:367 runtime.gopark (0x1035232) [force gc (idle)] Goroutine 3 - User: /usr/local/opt/go/libexec/src/runtime/proc.go:367 runtime.gopark (0x1035232) [GC sweep wait] Goroutine 4 - User: /usr/local/opt/go/libexec/src/runtime/proc.go:367 runtime.gopark (0x1035232) [GC scavenge wait] Goroutine 5 - User: /usr/local/opt/go/libexec/src/runtime/proc.go:367 runtime.gopark (0x1035232) [finalizer wait]
登录后复制
(dlv) bt 0 0x0000000001047e15 in runtime.growslice at /usr/local/opt/go/libexec/src/runtime/slice.go:183 1 0x00000000010aba6f in main.main at ./main.go:7 2 0x0000000001034e13 in runtime.main at /usr/local/opt/go/libexec/src/runtime/proc.go:255 3 0x000000000105f9c1 in runtime.goexit at /usr/local/opt/go/libexec/src/runtime/asm_amd64.s:1581
登录后复制
(dlv) regs Rip = 0x0000000001047e15 Rsp = 0x000000c00010de68 Rax = 0x00000000010b2f00 Rbx = 0x0000000000000000 Rcx = 0x0000000000000000 Rdx = 0x0000000000000008 Rsi = 0x0000000000000001 Rdi = 0x0000000000000000 Rbp = 0x000000c00010ded0 R8 = 0x0000000000000000 R9 = 0x0000000000000008 R10 = 0x0000000001088c40 R11 = 0x0000000000000246 R12 = 0x000000c00010df60 R13 = 0x0000000000000000 R14 = 0x000000c0000001a0 R15 = 0x00000000000000c8 Rflags = 0x0000000000000202 [IF IOPL=0] Cs = 0x000000000000002b Fs = 0x0000000000000000 Gs = 0x0000000000000000
登录后复制
(dlv) locals newcap = 1 doublecap = 0
登录后复制
总结
看源代码的过程是没有捷径可走的,如果说有,那就是可以先看一些大佬输出的底层原理的文章,然后参照其文章一步步入门源码阅读,最终还是要自己去克服这个困难,本文介绍了我自己查看源码的一些方式,你是否有更简便的方式呢?欢迎评论区分享出来~。
以上就是分享如何阅读Go源码的详细内容,更多请关注Work网其它相关文章!