Add auto indent

This commit is contained in:
Zachary Yedidia
2016-04-20 21:47:52 -04:00
parent 6aab17f445
commit 6d3344e4bd
3 changed files with 24 additions and 2 deletions

View File

@@ -75,3 +75,16 @@ func Contains(list []string, a string) bool {
func Insert(str string, pos int, value string) string {
return string([]rune(str)[:pos]) + value + string([]rune(str)[pos:])
}
// GetLeadingWhitespace returns the leading whitespace of the given string
func GetLeadingWhitespace(str string) string {
ws := ""
for _, c := range str {
if c == ' ' || c == '\t' {
ws += string(c)
} else {
break
}
}
return ws
}