diff --git a/strutil/string.go b/strutil/string.go new file mode 100644 index 0000000..70f3000 --- /dev/null +++ b/strutil/string.go @@ -0,0 +1,24 @@ +package strutil + +import "strings" + +func PadRight(s string, padStr string, overallLen int) string { + var padCountInt = 1 + ((overallLen - len(padStr)) / len(padStr)) + var retStr = s + strings.Repeat(padStr, padCountInt) + return retStr[:overallLen] +} + +func PadLeft(s string, padStr string, overallLen int) string { + var padCountInt = 1 + ((overallLen - len(padStr)) / len(padStr)) + var retStr = strings.Repeat(padStr, padCountInt) + s + return retStr[(len(retStr) - overallLen):] +} + +func StringInSlice(list []string, a string) bool { + for _, b := range list { + if b == a { + return true + } + } + return false +}