github.com/wfusion/gofusion@v1.1.14/common/infra/watermill/pkg/name.go (about) 1 package pkg 2 3 import ( 4 "fmt" 5 "strings" 6 ) 7 8 // StructName returns a normalized name of the passed structure. 9 func StructName(v any) string { 10 if s, ok := v.(fmt.Stringer); ok { 11 return s.String() 12 } 13 14 s := fmt.Sprintf("%T", v) 15 // trim the pointer marker, if any 16 return strings.TrimLeft(s, "*") 17 }