dlv
dlv類似c語言中的gdb偏序,但是會比gdb更好用一些
如果調(diào)試core文件 ./dlv core ./bin(二進(jìn)制產(chǎn)出) core.1234
args: 當(dāng)前變量
p:就是print
race
如果go程序出現(xiàn)core赫冬,且出現(xiàn)類似錯誤: panic: runtime error: invalid memory address or nil pointer dereference
可以使用race查看gorountine之間是否存在數(shù)據(jù)競爭關(guān)系
如果是大型項(xiàng)目: 可以在編譯二進(jìn)制的時(shí)候加上race:go build -race bin(二進(jìn)制產(chǎn)出)
然后在執(zhí)行bin文件的時(shí)候怠褐,會發(fā)現(xiàn)
image.png
pprof的使用
go tool pprof ./bin http://localhost:port/debug/pprof/heap
image.png
image.png
failed to execute dot. Is Graphviz installed? Error: exec: "dot": executable file not found in $PATH
sudo yum install graphviz
exec: "sensible-browser": executable file not found in $PATH
sudo yum install -y sensible-utils