convutil

package
v1.9.5 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2023 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Yotta SIExponents = 24
	Zetta             = 21
	Exa               = 18
	Peta              = 15
	Tera              = 12
	Giga              = 9
	Mega              = 6
	Kilo              = 3
	Hecto             = 2
	Deca              = 1
	Deci              = -1
	Centi             = -2
	Milli             = -3
	Micro             = -6
	Nano              = -9
	Pico              = -12
	Femto             = -15
	Atto              = -18
	Zepto             = -21
	Yocto             = -24
)

Variables

View Source
var ConvertRoundToPlaces = 6

Functions

func Convert

func Convert(in interface{}, from interface{}, to interface{}) (float64, error)

func ExactConvert

func ExactConvert(in interface{}, from interface{}, to interface{}) (float64, error)

func MustConvert

func MustConvert(in interface{}, from interface{}, to interface{}) float64

func MustExactConvert

func MustExactConvert(in interface{}, from interface{}, to interface{}) float64

Types

type Bytes

type Bytes float64
const (
	Byte       Bytes = 1
	Kilobyte   Bytes = 1024
	Megabyte   Bytes = 1048576
	Gigabyte   Bytes = 1073741824
	Terabyte   Bytes = 1099511627776
	Petabyte   Bytes = 1125899906842624
	Exabyte    Bytes = 1152921504606846976
	Zettabyte  Bytes = 1180591620717411303424
	Yottabyte  Bytes = 1208925819614629174706176
	Brontobyte Bytes = 1237940039285380274899124224
)

func (Bytes) Auto

func (self Bytes) Auto() (float64, string)

func (Bytes) Convert

func (self Bytes) Convert(to Bytes) (float64, string)

func (Bytes) Format

func (self Bytes) Format(format string, as ...Bytes) string

func (Bytes) String

func (self Bytes) String() string

func (Bytes) To

func (self Bytes) To(unit Bytes) string

type SIExponents

type SIExponents int

type Unit

type Unit int
const (
	Invalid Unit = iota
	AU
	Celsius
	Fahrenheit
	Feet
	Kelvin
	KilometersPerHour
	Lightseconds
	Lightminutes
	Lightyears
	Meters
	MetersPerSecond
	Miles
	MilesPerHour
	NauticalMiles
)

func MustParseUnit

func MustParseUnit(unit string) Unit

func ParseUnit

func ParseUnit(unit string) (Unit, error)

func (Unit) Family

func (self Unit) Family() UnitFamily

func (Unit) IsValid

func (self Unit) IsValid() bool

func (Unit) LongString

func (self Unit) LongString() string

func (Unit) String

func (self Unit) String() string

type UnitFamily

type UnitFamily int
const (
	GeneralUnits UnitFamily = iota
	TemperatureUnits
	LengthUnits
	SpeedUnits
)

Jump to

Keyboard shortcuts

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