// StrLen returns the length of the data.
513612
func (db *DB) StrLen(key []byte) (int64, error) {
	s, err := db.GetSlice(key)
	if err != nil {
		return 0, err
	}

	n := s.Size()
	s.Free()
	return int64(n), nil
}
1177733
func (list *List) LastN(n int) []string {
	if list.length == 0 {
		return emptySlice()
	}
	return list.Slice(list.length-n, list.length-1)
}
1244348
func limit(s string, length int) string {
	if len(s) < length {
		return s
	}

	return s[:length]
}
484686
func truncateString(str string, num int) string {
	text := str
	if len(str) > num {
		if num > 3 {
			num -= 3
		}
		text = str[0:num] + "..."
	}
	return text
}
874021
func String(l int) string {
	bs := make([]byte, l)
	for i := range bs {
		bs[i] = randomCharset[defaultSecureRand.Intn(len(randomCharset))]
	}
	return string(bs)
}
34233
func (p *Prefix) Len() int {
	l, _ := p.Mask.Size()
	return l
}
1248168
func RandomLength(length int, lang string) (string, error) {
	return RandomLengthDelim(length, " ", lang)
}
1166407
func (s *StructStruct) string(n int) string {
	sname := s.Name()
	pad := strings.Repeat(" ", n)

	var res string
	res += fmt.Sprintf("%s%s {\n", pad, sname)

	var fn int
	for _, field := range s.data {
		var n int
		if emb := field.Embedded(); emb != nil {
			n = len(emb.Name())
		} else {
			n = len(field.Name())
		}
		if n > fn {
			fn = n
		}
	}

	f := fmt.Sprintf("%s%%%ds %%T\n", pad, fn+1)
	for _, field := range s.data {
		if emb := field.Embedded(); emb != nil {
			res += emb.string(n + fn)
			continue
		}
		res += fmt.Sprintf(f, field.Name(), field.value.Interface())
	}

	res += fmt.Sprintf("%s}\n", pad)
	return res
}
983826
func utf8StrLen(s string) int {
	for i, r := range s {
		for r == utf8.RuneError {
			// The RuneError value can be an error
			// sentinel value (if it's size 1) or the same
			// value encoded properly. Decode it to see if
			// it's the 1 byte sentinel value.
			_, size := utf8.DecodeRuneInString(s[i:])
			if size == 1 {
				return i
			}
		}
	}
	return len(s)
}
1302679
func (h Header) String() string {
	if h.Value == nil {
		return fmt.Sprintf("%s=nil", h.Key)
	}

	valueLen := len(h.Value)
	if valueLen == 0 {
		return fmt.Sprintf("%s=<empty>", h.Key)
	}

	truncSize := valueLen
	trunc := ""
	if valueLen > 50+15 {
		truncSize = 50
		trunc = fmt.Sprintf("(%d more bytes)", valueLen-truncSize)
	}

	return fmt.Sprintf("%s=%s%s", h.Key, strconv.Quote(string(h.Value[:truncSize])), trunc)
}
383474
func (c Case) ShortString(length int) string {
	return fmt.Sprintf("%s%d [%s, %s]: %s(%s) = %s %s",
		c.Prefix, c.Prec, c.Trap, c.Mode, c.Op,
		join(c.Inputs, ", ", length), trunc(c.Output, length), c.Excep)
}
301027
func RandomString(length int) string {
	var dat = make([]byte, length)
	rand.Read(dat)
	return base64.StdEncoding.EncodeToString(dat)
}
423131
func (v *Value) String() string {
	return fmt.Sprintf("count:%d bytes:%d", v.Count, v.Bytes)
}
136963
func (b *Bar) String() string {
	var buf bytes.Buffer

	data := struct {
		Value          float64
		Total          float64
		Percent        float64
		StartDelimiter string
		EndDelimiter   string
		Bar            string
		Text           string
	}{
		Value:          b.value,
		Text:           b.text,
		StartDelimiter: b.StartDelimiter,
		EndDelimiter:   b.EndDelimiter,
		Percent:        b.percent(),
		Bar:            b.bar(),
	}

	if err := b.tmpl.Execute(&buf, data); err != nil {
		panic(err)
	}

	return buf.String()
}
1153666
func Longest(strs []string) string {
	if len(strs) == 0 {
		return ""
	}

	var longest string
	var llen int
	for _, str := range strs {
		if len(str) >= llen {
			longest = str
			llen = len(longest)
		}
	}

	return longest
}
506248
func (sc *StringConstraint) MinLength(l int) *StringConstraint {
	sc.minLength = l
	return sc
}
204396
func CharactersN(n int) string {
	var chars []string
	for i := 0; i < n; i++ {
		chars = append(chars, Character())
	}
	return strings.Join(chars, "")
}