Add MustEncodeToString for convenience.
This commit is contained in:
parent
ffc7c1e89b
commit
942bf31ab6
@ -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{}
|
||||
|
Loading…
Reference in New Issue
Block a user