Skip to content

Instantly share code, notes, and snippets.

View salihzain's full-sized avatar

Salih Zain salihzain

View GitHub Profile
@salihzain
salihzain / main.go
Created January 15, 2021 11:18
Go code to get the name of the function that invoked the current function
package main
import (
"fmt"
"runtime"
)
// whoCalledMe is a function that returns the name, fileName, and lineNumber of the caller that called function X
// the code doesn't check for edge cases
func whoCalledMe() (callerName, callerFileName string, callerLineNumber int) {