utils.go: new function typeName()

This commit is contained in:
Celestino Amoroso 2024-06-05 05:01:34 +02:00
parent d96123ab02
commit ca12722c93

View File

@ -217,3 +217,17 @@ func ForAll[T, V any](ts []T, fn func(T) V) []V {
}
return result
}
func typeName(v any) (s string) {
if v != nil {
if typer,ok:=v.(Typer);ok {
s = typer.TypeName()
}else{
s=fmt.Sprintf("%T", v)
}
} else {
s = "nil"
}
return
}