Skip to content

Instantly share code, notes, and snippets.

@sirenko
Created July 8, 2021 01:58
Show Gist options
  • Save sirenko/62af2ced43e393c23058e1201bd1504e to your computer and use it in GitHub Desktop.
Save sirenko/62af2ced43e393c23058e1201bd1504e to your computer and use it in GitHub Desktop.
import (
"reflect"
"runtime"
"strings"
)
// GetFuncName returns function name referenced by 'f'
func GetFuncName(f interface{}) string {
return strings.Split(runtime.FuncForPC(reflect.ValueOf(f).Pointer()).Name(), ".")[1]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment