cli/pkg/text/indent.go
2020-08-25 20:20:44 +02:00

15 lines
231 B
Go

package text
import (
"regexp"
"strings"
)
var lineRE = regexp.MustCompile(`(?m)^`)
func Indent(s, indent string) string {
if len(strings.TrimSpace(s)) == 0 {
return s
}
return lineRE.ReplaceAllLiteralString(s, indent)
}