(val interface{})
| 78 | } |
| 79 | |
| 80 | func GetStringRepresentationOfInterface(val interface{}) string { |
| 81 | if str, ok := val.(string); ok { |
| 82 | return str |
| 83 | } else if i, ok := val.(int64); ok { // these default to int64 so not sure how this would affect 32 bit systems TODO |
| 84 | return fmt.Sprintf("%d", i) |
| 85 | } else if i, ok := val.(int32); ok { // these default to int32 so not sure how this would affect 32 bit systems TODO |
| 86 | return fmt.Sprintf("%d", i) |
| 87 | } else if i, ok := val.(float64); ok { |
| 88 | return fmt.Sprintf("%.2f", i) |
| 89 | } else if i, ok := val.(float32); ok { |
| 90 | return fmt.Sprintf("%.2f", i) |
| 91 | } else if t, ok := val.(time.Time); ok { |
| 92 | str := t.String() |
| 93 | return str |
| 94 | } else if val == nil { |
| 95 | return "NULL" |
| 96 | } |
| 97 | |
| 98 | return "" |
| 99 | } |
| 100 | |
| 101 | func WriteCSV(m *TuiModel) { // basically display table but without any styling |
| 102 | if m.QueryData == nil || m.QueryResult == nil { |
no test coverage detected