diff options
| author | Dave Henderson <dhenderson@gmail.com> | 2017-05-12 09:11:52 -0400 |
|---|---|---|
| committer | Dave Henderson <dhenderson@gmail.com> | 2017-05-12 09:16:01 -0400 |
| commit | 617e2e9df2aed6c17a4eee7b3b963a2388a1ec11 (patch) | |
| tree | ac470906d012520bb9f1e574a44521c0447ed1cf /typeconv.go | |
| parent | ebb865e7d178ff5d09a6bd748b86b03c6ee59b5f (diff) | |
Adding new indent function
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'typeconv.go')
| -rw-r--r-- | typeconv.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/typeconv.go b/typeconv.go index fb8c0e5f..76739b3f 100644 --- a/typeconv.go +++ b/typeconv.go @@ -99,6 +99,21 @@ func (t *TypeConv) Slice(args ...interface{}) []interface{} { return args } +// Indent - indent each line of the string with the given indent string +func (t *TypeConv) indent(indent, s string) string { + var res []byte + bol := true + for i := 0; i < len(s); i++ { + c := s[i] + if bol && c != '\n' { + res = append(res, indent...) + } + res = append(res, c) + bol = c == '\n' + } + return string(res) +} + // Join concatenates the elements of a to create a single string. // The separator string sep is placed between elements in the resulting string. // |
