func Center(str string, length int, pad string) string {
	l := Len(str)
	if l >= length || pad == "" {
		return str
	}
	remains := length - l
	padLen := Len(pad)
	output := &bytes.Buffer{}
	output.Grow(len(str) + (remains/padLen+1)*len(pad))
	writePadString(output, pad, padLen, remains/2)
	output.WriteString(str)
	writePadString(output, pad, padLen, (remains+1)/2)
	return output.String()
}
Center returns a string with pad string at both side if str's rune length is smaller than length.
If str's rune length is larger than length, str itself will be returned.

If pad is an empty string, str will be returned.

Samples:
Center("hello", 4, " ")    => "hello"
Center("hello", 10, " ")   => "  hello   "
Center("hello", 10, "123") => "12hello123"
package xstrings
import (
	"bytes"
	"unicode/utf8"
)
func ExpandTabs(str string, tabSize int) string {
	if tabSize <= 0 {
		panic("tab size must be positive")
	}
	var r rune
	var i, size, column, expand int
	var output *bytes.Buffer
	orig := str
	for len(str) > 0 {
		r, size = utf8.DecodeRuneInString(str)
		if r == '\t' {
			expand = tabSize - column%tabSize
			if output == nil {
				output = allocBuffer(orig, str)
			}
			for i = 0; i < expand; i++ {
				output.WriteByte(byte(' '))
			}
			column += expand
		} else {
			if r == '\n' {
				column = 0
			} else {
				column += RuneWidth(r)
			}
			if output != nil {
				output.WriteRune(r)
			}
		}
		str = str[size:]
	}
	if output == nil {
		return orig
	}
	return output.String()
}
func LeftJustify(str string, length int, pad string) string {
	l := Len(str)
	if l >= length || pad == "" {
		return str
	}
	remains := length - l
	padLen := Len(pad)
	output := &bytes.Buffer{}
	output.Grow(len(str) + (remains/padLen+1)*len(pad))
	output.WriteString(str)
	writePadString(output, pad, padLen, remains)
	return output.String()
}
func RightJustify(str string, length int, pad string) string {
	l := Len(str)
	if l >= length || pad == "" {
		return str
	}
	remains := length - l
	padLen := Len(pad)
	output := &bytes.Buffer{}
	output.Grow(len(str) + (remains/padLen+1)*len(pad))
	writePadString(output, pad, padLen, remains)
	output.WriteString(str)
	return output.String()
}