IndentString

Indents each line in the provided string.

  • Use strings.Replace() to prepend i to each line.
import "strings"

func Indent(s, i string) string {
    return i + strings.Replace(s, "\n", "\n"+i, -1)
}
Indent("Lorem\nIpsum","_") // "_Lorem\n_Ipsum"