internal/prnt: trim trailing comment whitespace (#114)
Before printing a comment, remove trailing whitespace. Generation would output `// ` for empty comments. So we trim the whitespace off the end before printing.
This commit is contained in:
committed by
Michael McLoughlin
parent
205fc6a3d7
commit
3c861c7c0b
@@ -5,6 +5,7 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Generator provides convenience methods for code generators. In particular it
|
||||
@@ -38,7 +39,8 @@ func (g *Generator) NL() {
|
||||
// Comment writes comment lines prefixed with "// ".
|
||||
func (g *Generator) Comment(lines ...string) {
|
||||
for _, line := range lines {
|
||||
g.Printf("// %s\n", line)
|
||||
line = strings.TrimSpace("// " + line)
|
||||
g.Printf("%s\n", line)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user