mirror of https://github.com/miguelmota/cointop
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
447 B
Go
20 lines
447 B
Go
7 years ago
|
package pad
|
||
|
|
||
|
func times(str string, n int) (out string) {
|
||
|
for i := 0; i < n; i++ {
|
||
|
out += str
|
||
|
}
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// Left left-pads the string with pad up to len runes
|
||
|
// len may be exceeded if
|
||
|
func Left(str string, length int, pad string) string {
|
||
|
return times(pad, length-len(str)) + str
|
||
|
}
|
||
|
|
||
|
// Right right-pads the string with pad up to len runes
|
||
|
func Right(str string, length int, pad string) string {
|
||
|
return str + times(pad, length-len(str))
|
||
|
}
|