format: fix crash when emitting empty messages in text format
This commit is contained in:
parent
36f9e53dfd
commit
b8b0a5b5c3
|
|
@ -179,7 +179,7 @@ func (tf *textFormatter) format(m proto.Message) (string, error) {
|
||||||
|
|
||||||
// no trailing newline needed
|
// no trailing newline needed
|
||||||
str := buf.String()
|
str := buf.String()
|
||||||
if str[len(str)-1] == '\n' {
|
if len(str) > 0 && str[len(str)-1] == '\n' {
|
||||||
str = str[:len(str)-1]
|
str = str[:len(str)-1]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue