2
0
mirror of https://github.com/miguelmota/cointop synced 2024-11-18 15:25:31 +00:00
cointop/pkg/pad/pad.go
Miguel Mota 77f5c752e9 build script
Former-commit-id: 807a38499b5e912a909d18e142ac5ffd27518f47 [formerly 807a38499b5e912a909d18e142ac5ffd27518f47 [formerly 3b23f739d91859165827c1af6a923cf7be19a1d5 [formerly 6f3f3dd824]]]
Former-commit-id: 36948040aa5bec0dd2c25ec210e02349f5bddf0a
Former-commit-id: 4b1b9d17fc425bc764a46d0fdcd12747cca608f5 [formerly 56d4451c69972aa25ed17119773e6af9085b00c1]
Former-commit-id: 7967040e3a6348128010d3bc0ad213e5eabbf567
2018-03-31 01:18:53 -07:00

20 lines
447 B
Go

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))
}