CSVString - convert to string for CSV serialization
()
| 300 | |
| 301 | // CSVString - convert to string for CSV serialization |
| 302 | func (v Value) CSVString() string { |
| 303 | switch x := v.value.(type) { |
| 304 | case nil, Missing: |
| 305 | return "" |
| 306 | case bool: |
| 307 | if x { |
| 308 | return "true" |
| 309 | } |
| 310 | return "false" |
| 311 | case string: |
| 312 | return x |
| 313 | case int64: |
| 314 | return strconv.FormatInt(x, 10) |
| 315 | case float64: |
| 316 | return strconv.FormatFloat(x, 'g', -1, 64) |
| 317 | case time.Time: |
| 318 | return FormatSQLTimestamp(x) |
| 319 | case []byte: |
| 320 | return string(x) |
| 321 | case []Value: |
| 322 | b, _ := json.Marshal(x) |
| 323 | return string(b) |
| 324 | |
| 325 | default: |
| 326 | return "CSV serialization not implemented for this type" |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | // negate negates a numeric value |
| 331 | func (v *Value) negate() { |