You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
403 B

  1. package common
  2. import (
  3. "fmt"
  4. "strings"
  5. )
  6. var Fmt = fmt.Sprintf
  7. func RightPadString(s string, totalLength int) string {
  8. remaining := totalLength - len(s)
  9. if remaining > 0 {
  10. s = s + strings.Repeat(" ", remaining)
  11. }
  12. return s
  13. }
  14. func LeftPadString(s string, totalLength int) string {
  15. remaining := totalLength - len(s)
  16. if remaining > 0 {
  17. s = strings.Repeat(" ", remaining) + s
  18. }
  19. return s
  20. }