MCPcopy Create free account
hub / github.com/goadesign/goa / Comment

Function Comment

codegen/funcs.go:56–72  ·  view source on GitHub ↗

Comment produces line comments by concatenating the given strings and producing 80 characters long lines starting with "//".

(elems ...string)

Source from the content-addressed store, hash-verified

54// Comment produces line comments by concatenating the given strings and
55// producing 80 characters long lines starting with "//".
56func 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.

Callers 3

goTypeDefFunction · 0.92
protoBufMessageDefFunction · 0.92

Calls 3

IndentFunction · 0.85
WrapTextFunction · 0.85
CountMethod · 0.80

Tested by

no test coverage detected