Comment produces line comments by concatenating the given strings and producing 80 characters long lines starting with "//".
(elems ...string)
| 54 | // Comment produces line comments by concatenating the given strings and |
| 55 | // producing 80 characters long lines starting with "//". |
| 56 | func Comment(elems ...string) string { |
| 57 | lineCount := 0 |
| 58 | for _, e := range elems { |
| 59 | lineCount += strings.Count(e, "\n") + 1 |
| 60 | } |
| 61 | lines := make([]string, 0, lineCount) |
| 62 | for _, e := range elems { |
| 63 | lines = append(lines, strings.Split(e, "\n")...) |
| 64 | } |
| 65 | var trimmed = make([]string, len(lines)) |
| 66 | for i, l := range lines { |
| 67 | trimmed[i] = strings.TrimLeft(l, " \t") |
| 68 | } |
| 69 | t := strings.Join(trimmed, "\n") |
| 70 | |
| 71 | return Indent(WrapText(t, 77), "// ") |
| 72 | } |
| 73 | |
| 74 | // Indent inserts prefix at the beginning of each non-empty line of s. The |
| 75 | // end-of-line marker is NL. |
no test coverage detected