I'm looking for a way to write to log a traceback stack in golang, but only some lines from it. As I see it, it could be done by splitting the result obtained from debug.Stack() into a slice of structures, which could be then easily parsed.
this is what I get now with this call "fmt.Println(string(debug.Stack()))":
goroutine 1 [running]:
runtime/debug.Stack(0xc0000c0050, 0x2, 0x0)
/go/go1.15rc1/src/runtime/debug/stack.go:24 +0x9f
main.go_logger(0x4cc235, 0x11, 0x4ccf9d, 0x15, 0xc000090101)
/go/src/ethernet_monitor/info.go:30 +0x290
main.temp(...)
/go/src/ethernet_monitor/info.go:40
main.main()
/go/src/ethernet_monitor/info.go:45 +0x52
and that is the way I want it to be split, similar to python's traceback.extract_stack() structure:
fileName: /go/src/ethernet_monitor/info.go
function: main.main()
lineNumber: 45
So the question is - is it implemented somehow already? I'm not very confident writing my own parsing function as I might miss some specific cases.