Skip to content

Instantly share code, notes, and snippets.

@BetterProgramming
Created November 8, 2022 20:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BetterProgramming/fb44b6649e5857ea992a9e68f56d1cf7 to your computer and use it in GitHub Desktop.
Save BetterProgramming/fb44b6649e5857ea992a9e68f56d1cf7 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"runtime"
)
func main() {
for i := 0 ; i< 4; i++ {
test(i)
}
}
func test(skip int) {
call(skip)
}
func call(skip int) {
pc,file,line,ok := runtime.Caller(skip)
pcName := runtime.FuncForPC(pc).Name()
fmt.Println(fmt.Sprintf("%v %s %d %t %s",pc,file,line,ok,pcName))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment