Skip to content

Instantly share code, notes, and snippets.

@tsyber1an
Created November 11, 2021 09:26
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 tsyber1an/155300cc866e6a27a7e650b246cf73b5 to your computer and use it in GitHub Desktop.
Save tsyber1an/155300cc866e6a27a7e650b246cf73b5 to your computer and use it in GitHub Desktop.
runtime.Caller example
package main
import (
"fmt"
"runtime"
)
func foo() {
_, file, no, ok := runtime.Caller(1)
if ok {
fmt.Printf("called from %s#%d\n", file, no)
}
}
func main() {
foo()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment