go-units

module
v0.0.0-...-63d2a97 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2025 License: Apache-2.0

README

Go Units

This Go library represents physical units like length, area, speed, and temperature as typed floating point numbers. Methods to convert between metric and US customary units of measurement are provided on each type. Additional units can be created by multiplying by const values and variables can be converted by casting. See this example snippet for the exact syntax.

Unit types are represented as a float64 in the base SI measure: meters, square meters, meters per second, and Kelvin. Working with very large or very small values relative to the base SI unit will lose some precision: the distance from the Sun to Alpha Centauri in meters is near the precision limit of 64-bit floating point numbers, and the distance to the edge of universe cannot be represented as a unit.Length. Likewise, subatomic measurements will not be precise.

See full documentation at https://pkg.go.dev/github.com/google/go-units

This is not an officially supported Google product. This project is not eligible for the Google Open Source Software Vulnerability Rewards Program.

Directories

Path Synopsis
Package unit implements types and functions for working with units of measurement.
Package unit implements types and functions for working with units of measurement.

Jump to

Keyboard shortcuts

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