March 2020
Intermediate to advanced
406 pages
8h 39m
English
GOTRACEBACK allows you to control the generated output from a Go program with unexpected runtime conditions or unrecovered panic states. Setting a GOTRACEBACK variable will allow you to see more or less granular information about the goroutines that are instantiated for your specific error or panic. An example of panic from a channel/goroutine interrupt is as follows:
package mainimport ( "time")func main() { c := make(chan bool, 1) go panicRoutine(c) for i := 0; i < 2; i++ { <-c }}func panicRoutine(c chan bool) { time.Sleep(100 * time.Millisecond) panic("Goroutine Panic") c <- true}
If we tweak the GOTRACEBACK variable in our output, we will see different varying levels of stack trace. Setting GOTRACEBACK=none or GOTRACEBACK=0 ...
Read now
Unlock full access