numstr

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 2 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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