From 617e2e9df2aed6c17a4eee7b3b963a2388a1ec11 Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Fri, 12 May 2017 09:11:52 -0400 Subject: Adding new indent function Signed-off-by: Dave Henderson --- typeconv.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'typeconv.go') 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. // -- cgit v1.2.3