Hi! In this example $v
is a structure (it contains Labels and a Value). When we attempt to print this structure in a template with $v
it calls the String
method on this structure, which returns the floating point value as a string without rounding to some number of decimal places.
{{ with $values }}{{ range $k, $v := . }}CPU: {{ printf "%.2f" $v }}%
{{ end }} {{ end }}
To use the raw floating point value just change the argument to printf from $v
to $v.Value
:
{{ with $values }}{{ range $k, $v := . }}CPU: {{ printf "%.2f" $v.Value }}%
{{ end }} {{ end }}