numstr

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 21, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package numstr encodes and decodes the numeric-valued strings used in CRD status fields.

Several status fields (goodput ratios, step times, bandwidths) are typed as strings rather than floats: the Kubernetes API rejects NaN and Inf in numeric fields, and float round-tripping through JSON is lossy in ways that produce noisy status diffs. Storing a fixed-precision decimal string avoids both.

This package exists because the decode half was previously reimplemented in three packages with divergent behaviour — one used fmt.Sscanf, which silently accepts trailing garbage ("1.5abc" → 1.5) where the others returned 0. Since producer and consumer of these strings must agree, both halves live here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format

func Format(f float64) string

Format encodes a float for storage in a status string field.

func Parse

func Parse(s string) float64

Parse decodes a numeric status string. It returns 0 for empty, malformed, or partially-numeric input, which is the appropriate zero value for every caller: these fields are absent until the controller has measured something, and an unset field must not read as a real measurement.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL