yamlzero

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 2 Imported by: 0 modules, 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 yamlzero normalizes IEEE 754 negative zero (-0.0) floats to positive zero (0.0) in Go values decoded from or encoded to YAML.

go.yaml.in/yaml/v3 formats a negative zero float as the plain scalar "-0", which YAML reads back as the integer 0, causing the next save to rewrite the field as "0". Normalizing on parse keeps parsed values free of negative zero in memory, and cleaning on encode guarantees idempotent round trips without mutating caller-owned values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clean

func Clean[T any](v T) T

Clean returns v unchanged when it contains no negative zero float32 or float64. Otherwise it returns a copy along the paths containing negative zero with every negative zero replaced by positive zero, without mutating v.

func Has

func Has(v any) bool

Has reports whether v contains any reachable float32 or float64 negative zero. It never mutates v and does not allocate when inspecting structs, pointers, slices, arrays, or interfaces.

func Normalize

func Normalize(v any)

Normalize replaces every reachable negative zero float32 and float64 in v with positive zero in place. Pass a pointer (or a slice/map) to mutate top-level values. When no negative zero is present in maps or interfaces, Normalize does not allocate.

Types

This section is empty.

Jump to

Keyboard shortcuts

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