From 3f581b433adb5d4c4129121dc1b7fea0b46ad1b2 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Wed, 25 Nov 2020 09:27:18 +0100 Subject: pkg/ast: remove trailing spaces when formatting --- pkg/ast/format.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'pkg/ast') diff --git a/pkg/ast/format.go b/pkg/ast/format.go index 6b16f4015..51538eaf1 100644 --- a/pkg/ast/format.go +++ b/pkg/ast/format.go @@ -7,6 +7,7 @@ import ( "bytes" "fmt" "io" + "strings" ) func Format(desc *Description) []byte { @@ -70,7 +71,7 @@ func (n *NewLine) serialize(w io.Writer) { } func (n *Comment) serialize(w io.Writer) { - fmt.Fprintf(w, "#%v\n", n.Text) + fmt.Fprintf(w, "#%v\n", strings.TrimRight(n.Text, " \t")) } func (n *Include) serialize(w io.Writer) { @@ -138,7 +139,7 @@ func (n *Struct) serialize(w io.Writer) { fmt.Fprintf(w, "\n") } for _, com := range f.Comments { - fmt.Fprintf(w, "#%v\n", com.Text) + com.serialize(w) } fmt.Fprintf(w, "\t%v\t", f.Name.Name) for tabs := len(f.Name.Name)/tabWidth + 1; tabs < maxTabs; tabs++ { @@ -151,7 +152,7 @@ func (n *Struct) serialize(w io.Writer) { fmt.Fprintf(w, "\n") } for _, com := range n.Comments { - fmt.Fprintf(w, "#%v\n", com.Text) + com.serialize(w) } fmt.Fprintf(w, "%c", closing) if attrs := fmtTypeList(n.Attrs, "[", "]"); attrs != "" { -- cgit mrf-deployment