String returns the value always as a string
()
| 19 | |
| 20 | // String returns the value always as a string |
| 21 | func (v *Value) String() string { |
| 22 | switch { |
| 23 | case v.IsNil(): |
| 24 | return "" |
| 25 | case v.IsStr(): |
| 26 | return v.Str() |
| 27 | case v.IsBool(): |
| 28 | return strconv.FormatBool(v.Bool()) |
| 29 | case v.IsFloat32(): |
| 30 | return strconv.FormatFloat(float64(v.Float32()), 'f', -1, 32) |
| 31 | case v.IsFloat64(): |
| 32 | return strconv.FormatFloat(v.Float64(), 'f', -1, 64) |
| 33 | case v.IsInt(): |
| 34 | return strconv.FormatInt(int64(v.Int()), 10) |
| 35 | case v.IsInt8(): |
| 36 | return strconv.FormatInt(int64(v.Int8()), 10) |
| 37 | case v.IsInt16(): |
| 38 | return strconv.FormatInt(int64(v.Int16()), 10) |
| 39 | case v.IsInt32(): |
| 40 | return strconv.FormatInt(int64(v.Int32()), 10) |
| 41 | case v.IsInt64(): |
| 42 | return strconv.FormatInt(v.Int64(), 10) |
| 43 | case v.IsUint(): |
| 44 | return strconv.FormatUint(uint64(v.Uint()), 10) |
| 45 | case v.IsUint8(): |
| 46 | return strconv.FormatUint(uint64(v.Uint8()), 10) |
| 47 | case v.IsUint16(): |
| 48 | return strconv.FormatUint(uint64(v.Uint16()), 10) |
| 49 | case v.IsUint32(): |
| 50 | return strconv.FormatUint(uint64(v.Uint32()), 10) |
| 51 | case v.IsUint64(): |
| 52 | return strconv.FormatUint(v.Uint64(), 10) |
| 53 | } |
| 54 | return fmt.Sprintf("%#v", v.Data()) |
| 55 | } |
| 56 | |
| 57 | // StringSlice returns the value always as a []string |
| 58 | func (v *Value) StringSlice(optionalDefault ...[]string) []string { |