github.com/andrewhsu/cli/v2@v2.0.1-0.20210910131313-d4b4061f5b89/pkg/text/indent.go (about) 1 package text 2 3 import ( 4 "regexp" 5 "strings" 6 ) 7 8 var lineRE = regexp.MustCompile(`(?m)^`) 9 10 func Indent(s, indent string) string { 11 if len(strings.TrimSpace(s)) == 0 { 12 return s 13 } 14 return lineRE.ReplaceAllLiteralString(s, indent) 15 }