23 lines
312 B
Go
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)
|
|
}
|