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

Function Indent

codegen/funcs.go:76–91  ·  view source on GitHub ↗

Indent inserts prefix at the beginning of each non-empty line of s. The end-of-line marker is NL.

(s, prefix string)

Source from the content-addressed store, hash-verified

74// Indent inserts prefix at the beginning of each non-empty line of s. The
75// end-of-line marker is NL.
76func Indent(s, prefix string) string {
77 var (
78 b = []byte(s)
79 p = []byte(prefix)
80 res = make([]byte, 0, len(b)+len(b)/4*len(p)) // preallocate with estimated size
81 bol = true
82 )
83 for _, c := range b {
84 if bol && c != '\n' {
85 res = append(res, p...)
86 }
87 res = append(res, c)
88 bol = c == '\n'
89 }
90 return string(res)
91}
92
93// Casing exceptions
94var toLower = map[string]string{"OAuth": "oauth"}

Callers 1

CommentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected