// String formats Size to human readable string with specified options.
// For example, 1024 bytes will return 1KB.
425180
func (s Size) Format(opts Options) string {
	var (
		unit  string
		value = float64(s)
	)

	switch {
	case s < KB:
		unit = "B"
	case s < MB:
		value /= KB
		unit = "KB"
	case s < GB:
		value /= MB
		unit = "MB"
	case s < TB:
		value /= GB
		unit = "GB"
	case s < PB:
		value /= TB
		unit = "TB"
	case s < EB:
		value /= PB
		unit = "PB"
	default:
		value /= EB
		unit = "EB"
	}

	ss := fmt.Sprintf("%."+strconv.Itoa(opts.Precision)+"f", value)
	i := len(ss) - 1
	for {
		r := ss[i]
		if r == '0' {
			i--
			continue
		}
		if r == '.' {
			ss = ss[:i]
		} else {
			ss = ss[:i+1]
		}
		break
	}

	if opts.Short && len(unit) > 1 {
		unit = unit[:1]
	}
	if opts.Space {
		return ss + " " + unit
	}
	return ss + unit
}
206223
func (k *Key) String() string {
	s := string(k.Format) + " " + base64.StdEncoding.EncodeToString(k.Blob)

	if k.Comment != "" {
		s += " " + k.Comment
	}

	return s
}
558750
func (e Encoding) String() string {
	switch e {
	case UTF8:
		return "UTF8"
	case UTF16BigEndian:
		return "UTF16BigEndian"
	case UTF16LittleEndian:
		return "UTF16LittleEndian"
	case UTF32BigEndian:
		return "UTF32BigEndian"
	case UTF32LittleEndian:
		return "UTF32LittleEndian"
	default:
		return "Unknown"
	}
}
1307810
func (v *KeyValue_SetValue_Args) String() string {
	if v == nil {
		return "<nil>"
	}

	var fields [2]string
	i := 0
	if v.Key != nil {
		fields[i] = fmt.Sprintf("Key: %v", *(v.Key))
		i++
	}
	if v.Value != nil {
		fields[i] = fmt.Sprintf("Value: %v", *(v.Value))
		i++
	}

	return fmt.Sprintf("KeyValue_SetValue_Args{%v}", strings.Join(fields[:i], ", "))
}
1185708
func (h *Height) String() string {
	return fmt.Sprintf("{BlockNum: %d, TxNum: %d}", h.BlockNum, h.TxNum)
}
712151
func (s *stack) String() string {
	var result string
	for _, stack := range s.stk {
		if len(stack) == 0 {
			result += "00000000  <empty>\n"
		}
		result += hex.Dump(stack)
	}

	return result
}
460199
func (s *StringLit) String() string {
	return fmt.Sprintf("%s: %T{Val: %q}", s.p, s, s.Val)
}
1134429
func (q *Quantity) String() string {
	number, suffix := q.Canonicalize()
	return number + string(suffix)
}
1081112
func (n *Namer) String() string {
	ext := n.opts.extension
	if n.count == 0 {
		return fmt.Sprintf("%s%s", n.opts.base, ext)
	}
	return fmt.Sprintf("%s%d%s", n.opts.base, n.count, ext)
}
33886
func (q *Quantity) String() string {
	if len(q.s) == 0 {
		result := make([]byte, 0, int64QuantityExpectedBytes)
		number, suffix := q.CanonicalizeBytes(result)
		number = append(number, suffix...)
		q.s = string(number)
	}
	return q.s
}
687251
func StringToBytes(s string) []byte {
	return *(*[]byte)(unsafe.Pointer(
		&struct {
			string
			Cap int
		}{s, len(s)},
	))
}
471826
func (d *MyDecimal) String() string {
	tmp := *d
	err := tmp.Round(&tmp, int(tmp.resultFrac), ModeHalfEven)
	terror.Log(errors.Trace(err))
	return string(tmp.ToString())
}
811047
func (b *HttpRequest) String() (string, error) {
	data, err := b.Bytes()
	if err != nil {
		return "", err
	}

	return string(data), nil
}
627837
func FormatByte(args ...interface{}) string {
	sizes := [...]string{"YB", "ZB", "EB", "PB", "TB", "GB", "MB", "KB", "B"}
	var (
		total     int     = len(sizes)
		size      float64 = 0
		precision int     = 0
	)
	ln := len(args)
	if ln > 0 {
		switch args[0].(type) {
		case float64:
			size = args[0].(float64)
		case float32:
			size = float64(args[0].(float32))
		case int64:
			size = float64(args[0].(int64))
		case int32:
			size = float64(args[0].(int32))
		case int:
			size = float64(args[0].(int))
		case uint64:
			size = float64(args[0].(uint64))
		case uint32:
			size = float64(args[0].(uint32))
		case uint:
			size = float64(args[0].(uint))
		case string:
			i, _ := strconv.Atoi(args[0].(string))
			size = float64(i)
		default:
			fmt.Printf("FormatByte error: first param (%#v) invalid.\n", args[0])
		}
	}
	if ln > 1 {
		switch args[1].(type) {
		case int:
			precision = args[1].(int)
		case int64:
			precision = int(args[1].(int64))
		case int32:
			precision = int(args[1].(int32))
		case uint:
			precision = int(args[1].(uint))
		case uint64:
			precision = int(args[1].(uint64))
		case uint32:
			precision = int(args[1].(uint32))
		default:
			fmt.Printf("FormatByte error: second param (%#v) invalid.\n", args[1])
		}
	}
	for total--; total > 0 && size > 1024.0; total-- {
		size /= 1024.0
	}
	return fmt.Sprintf("%.*f%s", precision, size, sizes[total])
}
65280
func (v Value) String() string {
	switch v.t {
	case reflect.String:
		return v.s
	case reflect.Int:
		return strconv.Itoa(v.i)
	case reflect.Bool:
		return strconv.FormatBool(v.b)
	}

	return ""
}
1334639
func FormatByte(args ...interface{}) string {
	sizes := [...]string{"YB", "ZB", "EB", "PB", "TB", "GB", "MB", "KB", "B"}
	var (
		total     = len(sizes)
		size      float64
		precision int
	)
	ln := len(args)
	if ln > 0 {
		switch v := args[0].(type) {
		case float64:
			size = v
		case float32:
			size = float64(v)
		case int64:
			size = float64(v)
		case int32:
			size = float64(v)
		case int:
			size = float64(v)
		case uint64:
			size = float64(v)
		case uint32:
			size = float64(v)
		case uint:
			size = float64(v)
		case string:
			i, _ := strconv.Atoi(v)
			size = float64(i)
		default:
			fmt.Printf("FormatByte error: first param (%#v) invalid.\n", args[0])
		}
	}
	if ln > 1 {
		switch v := args[1].(type) {
		case int:
			precision = v
		case int64:
			precision = int(v)
		case int32:
			precision = int(v)
		case uint:
			precision = int(v)
		case uint64:
			precision = int(v)
		case uint32:
			precision = int(v)
		default:
			fmt.Printf("FormatByte error: second param (%#v) invalid.\n", args[1])
		}
	}
	for total--; total > 0 && size > 1024.0; total-- {
		size /= 1024.0
	}
	return fmt.Sprintf("%.*f%s", precision, size, sizes[total])
}
1136843
func (v *Duration) String() string {
	return strconv.FormatInt(int64(v.i.Get()), 10)
}