Skip to content

Instantly share code, notes, and snippets.

@yinchunxiang
Last active July 2, 2016 06:18
Show Gist options
  • Save yinchunxiang/70e154f340bd27049bb5cea23c65d534 to your computer and use it in GitHub Desktop.
Save yinchunxiang/70e154f340bd27049bb5cea23c65d534 to your computer and use it in GitHub Desktop.
func trace() {
pc := make([]uintptr, 10) // at least 1 entry needed
runtime.Callers(2, pc)
f := runtime.FuncForPC(pc[0])
file, line := f.FileLine(pc[0])
fmt.Printf("%s:%d %s\n", file, line, f.Name())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment