yvbolt/format.go

23 lines
312 B
Go
Raw Permalink Normal View History

2024-06-08 03:02:02 +00:00
package main
import (
"fmt"
"unicode/utf8"
)
func formatUtf8(in []byte) string {
if !utf8.Valid(in) {
return fmt.Sprintf("<<Invalid UTF-8 %q>>", in)
}
return string(in)
}
func formatAny(in interface{}) string {
if _, ok := in.([]byte); ok {
return "<<binary>>"
}
return fmt.Sprintf("%#v", in)
}