MCPcopy Index your code
hub / github.com/rilldata/rill / FormatValue

Method FormatValue

cli/pkg/printer/printer.go:201–222  ·  view source on GitHub ↗

FormatValue formats a value for display, avoiding scientific notation for numbers

(val interface{})

Source from the content-addressed store, hash-verified

199
200// FormatValue formats a value for display, avoiding scientific notation for numbers
201func (p *Printer) FormatValue(val interface{}) string {
202 if val == nil {
203 return "null"
204 }
205
206 switch v := val.(type) {
207 case float64:
208 if v == float64(int64(v)) {
209 return strconv.FormatInt(int64(v), 10)
210 }
211 return strconv.FormatFloat(v, 'f', -1, 64)
212 case float32:
213 if v == float32(int32(v)) {
214 return strconv.FormatInt(int64(v), 10)
215 }
216 return strconv.FormatFloat(float64(v), 'f', -1, 32)
217 case int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64:
218 return fmt.Sprintf("%d", v)
219 default:
220 return fmt.Sprintf("%v", v)
221 }
222}

Callers 1

PrintQueryResponseMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected