YTSFlix_Go/vendor/github.com/asticode/go-astitools/string/length.go

16 lines
283 B
Go
Raw Normal View History

2018-11-04 14:58:15 +00:00
package astistring
// ToLength forces the length of a string
func ToLength(i, rpl string, length int) string {
if len(i) == length {
return i
} else if len(i) > length {
return i[:length]
} else {
for idx := 0; idx <= length-len(i); idx++ {
i += rpl
}
return i
}
}