func rpad()

in pkg/formatter/text_template_utils.go [41:79]


func rpad(s interface{}, padding int) string {
	var str = "-"
	template := fmt.Sprintf("%%-%ds", padding)
	switch t := s.(type) {
	case string:
		if t != "" {
			str = t
		}
	case *string:
		if t != nil {
			str = *t
		}
	case uint16:
		str = strconv.Itoa(int(t))
	case int32:
		str = strconv.Itoa(int(t))
	case *int32:
		str = strconv.Itoa(int(*t))
	case int64:
		str = strconv.Itoa(int(t))
	case int:
		str = strconv.Itoa(t)
	case bool:
		str = strconv.FormatBool(t)
	case *bool:
		if t == nil {
			str = "false"
		} else {
			str = strconv.FormatBool(*t)
		}
	case float64:
		str = strconv.FormatFloat(t, 'f', -1, 64)
	case *float64:
		str = strconv.FormatFloat(*t, 'f', -1, 64)
	default:
		return fmt.Sprintf(template, s)
	}
	return fmt.Sprintf(template, str)
}