aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2020-11-25 09:27:18 +0100
committerDmitry Vyukov <dvyukov@google.com>2020-11-25 10:02:24 +0100
commit3f581b433adb5d4c4129121dc1b7fea0b46ad1b2 (patch)
tree34c910585c940f026a0d00c8916ae66bcb49546b /pkg
parent1a1f4bd8c48f86af4bc94a2e3a86fc0de9c52c93 (diff)
pkg/ast: remove trailing spaces when formatting
Diffstat (limited to 'pkg')
-rw-r--r--pkg/ast/format.go7
1 files changed, 4 insertions, 3 deletions
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 != "" {