String returns a string representation of the value.
()
| 77 | |
| 78 | // String returns a string representation of the value. |
| 79 | func (t Result) String() string { |
| 80 | switch t.Type { |
| 81 | default: |
| 82 | return "" |
| 83 | case False: |
| 84 | return "false" |
| 85 | case Number: |
| 86 | if len(t.Raw) == 0 { |
| 87 | // calculated result |
| 88 | return strconv.FormatFloat(t.Num, 'f', -1, 64) |
| 89 | } |
| 90 | var i int |
| 91 | if t.Raw[0] == '-' { |
| 92 | i++ |
| 93 | } |
| 94 | for ; i < len(t.Raw); i++ { |
| 95 | if t.Raw[i] < '0' || t.Raw[i] > '9' { |
| 96 | return strconv.FormatFloat(t.Num, 'f', -1, 64) |
| 97 | } |
| 98 | } |
| 99 | return t.Raw |
| 100 | case String: |
| 101 | return t.Str |
| 102 | case JSON: |
| 103 | return t.Raw |
| 104 | case True: |
| 105 | return "true" |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | // Bool returns an boolean representation. |
| 110 | func (t Result) Bool() bool { |
no outgoing calls