diff --git a/utio/string.go b/utio/string.go index 6162403..5eb4cc8 100644 --- a/utio/string.go +++ b/utio/string.go @@ -17,6 +17,15 @@ func EncodeToString(e Encoder) (string, error) { return WriteToString(e.Encode) } +// MustEncodeToString returns the encoded string value and panics if an error has occurred +func MustEncodeToString(e Encoder) string { + s, err := WriteToString(e.Encode) + if err != nil { + panic(err) + } + return s +} + // WriteToString returns the string value of the data written to fn. func WriteToString(fn WriteFunc) (string, error) { var b = &bytes.Buffer{}