@@ -23,7 +23,7 @@ type Message struct {
2323
2424func (m * Message ) String () (text string ) {
2525 text += fmt .Sprintf ("Message (version: %d)" , m .Version )
26- for _ , line := range strings . Split ( m .Format .String (), " \n " ) {
26+ for _ , line := range m .Format .stringParts ( ) {
2727 text += "\n " + line
2828 }
2929 return
@@ -45,16 +45,22 @@ type Format struct {
4545}
4646
4747func (f * Format ) String () (text string ) {
48- text += fmt .Sprintf ("Format (Size: %d, LastNonIgnorableField: %d)\n " ,
49- f .Size , f .LastNonIgnorableField )
48+ return strings .Join (f .stringParts (), "\n " )
49+ }
50+
51+ func (f * Format ) stringParts () (parts []string ) {
52+
53+ parts = append (parts , fmt .Sprintf ("Format (Size: %d, LastNonIgnorableField: %d)" ,
54+ f .Size , f .LastNonIgnorableField ))
55+
5056 for _ , f := range f .Fields {
51- text += fmt .Sprintf ("Field %02d (Name: %s, Skipped: %t, Type: %T)\n " ,
52- f .ID , f .Name , f .Skipped , f .Type )
57+ parts = append ( parts , fmt .Sprintf ("Field %02d (Name: %s, Skipped: %t, Type: %T)" ,
58+ f .ID , f .Name , f .Skipped , f .Type ))
5359 if f .Type != nil {
54- text += fmt .Sprintf (" Value: %s\n " , f .Type .String ())
60+ parts = append ( parts , fmt .Sprintf (" Value: %s" , f .Type .String () ))
5561 }
5662 }
57- return text
63+ return
5864}
5965
6066// Field represents a `message_field`
0 commit comments