go version go1.8.3 darwin/amd64
ulimit -c unlimited
env GOTRACEBACK=crash ./testgotraceback.go
ls -al
no core file generated.
testgotraceback.go source filepackage main
import (
"fmt"
"time"
)
func saferoutine(c chan bool) {
for i := 0; i < 10; i++ {
fmt.Println("Count:", i)
time.Sleep(1 * time.Second)
}
c <- true
}
func panicgoroutine(c chan bool) {
time.Sleep(5 * time.Second)
panic("Panic, omg ...")
c <- true
}
func main() {
c := make(chan bool, 2)
go saferoutine(c)
go panicgoroutine(c)
for i := 0; i < 2; i++ {
<-c
}
}
I want to use core file to trace some error.But use the GOTRACEBACK=crash command,I find no core file.use golang1.7 as well. so ,what's the problem?thanks for help.
If you are expecting a core dump file to be created in the directory where you program is being run, you not only need to use ulimit and set GOTRACEBACK but also change settings on your operating system to save core file in the current directory.
Assuming you are using Linux, this is distribution-specific. You need to find relevant sysfs entry and save core value to it. For example, a core pattern sysfs entry on Fedora is /proc/sys/kernel/core_pattern and to setup you OS to save core files in the current directory, you would need to execute:
echo core > /proc/sys/kernel/core_pattern
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With