A golang implementation of the left-pad javascript library
I was inspired by Stew's left-cats
, who was inspired by this article, to port this to Go.
This implementation will let you pad byte-strings and UTF-8 encoded strings
example usage:
package main
import (
"fmt"
"github.com/willf/pad"
padUtf8 "github.com/willf/pad/utf8"
)
func main() {
fmt.Println(pad.Right("Hello", 20, "!"))
fmt.Println(padUtf8.Left("Exit now", 20, "→"))
}
> go run example.go
Hello!!!!!!!!!!!!!!!
→→→→→→→→→→→→Exit now