yvbolt/format.go
2024-06-08 15:02:02 +12:00

23 lines
312 B
Go

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)
}