convutil

package
v1.6.35 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2018 License: MIT Imports: 11 Imported by: 5

Documentation

Index

Constants

View Source
const (
	DistanceMeter        = 1
	DistanceKilometer    = 1000
	DistanceFoot         = 0.3048
	DistanceYard         = 0.9144
	DistanceMile         = 1609.344
	DistanceNauticalMile = 1852
)
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
)
View Source
const (
	SpeedMetersPerSecond = 1
	SpeedKPH             = 0.277778
	SpeedFeetPerSecond   = 0.3048
	SpeedMPH             = 0.44704
	SpeedMach            = 340.29
)

Variables

View Source
var ConvertRoundToPlaces = 6
View Source
var DistanceDisplayUnit = MeasurementSystem(Imperial)
View Source
var SpeedDisplayUnit = MeasurementSystem(Imperial)

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 added in v1.6.22

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 added in v1.6.22

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

func (Bytes) Convert added in v1.6.22

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

func (Bytes) Format added in v1.6.22

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

func (Bytes) String added in v1.6.22

func (self Bytes) String() string

func (Bytes) To added in v1.6.22

func (self Bytes) To(unit Bytes) string

type Distance added in v1.6.35

type Distance float64

func MustParseDistance added in v1.6.35

func MustParseDistance(in interface{}) Distance

func ParseDistance added in v1.6.35

func ParseDistance(in interface{}) (Distance, error)

func (Distance) Beyond added in v1.6.35

func (self Distance) Beyond(other Distance) bool

func (Distance) Equal added in v1.6.35

func (self Distance) Equal(other Distance) bool

func (Distance) ImperialString added in v1.6.35

func (self Distance) ImperialString() string

func (Distance) MarshalJSON added in v1.6.35

func (self Distance) MarshalJSON() ([]byte, error)

func (Distance) MetricString added in v1.6.35

func (self Distance) MetricString() string

func (Distance) String added in v1.6.35

func (self Distance) String() string

func (*Distance) UnmarshalJSON added in v1.6.35

func (self *Distance) UnmarshalJSON(data []byte) error

func (Distance) Within added in v1.6.35

func (self Distance) Within(other Distance) bool

type MeasurementSystem added in v1.6.35

type MeasurementSystem string
const (
	Metric   MeasurementSystem = `metric`
	Imperial                   = `imperial`
)

type SIExponents added in v1.6.22

type SIExponents int

type Speed added in v1.6.35

type Speed float64

func (Speed) Equal added in v1.6.35

func (self Speed) Equal(other Speed) bool

func (Speed) FasterThan added in v1.6.35

func (self Speed) FasterThan(other Speed) bool

func (Speed) MarshalJSON added in v1.6.35

func (self Speed) MarshalJSON() ([]byte, error)

func (Speed) SlowerThan added in v1.6.35

func (self Speed) SlowerThan(other Speed) bool

func (Speed) String added in v1.6.35

func (self Speed) String() string

func (*Speed) UnmarshalJSON added in v1.6.35

func (self *Speed) UnmarshalJSON(data []byte) error

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
	AbsoluteUnit = math.MaxInt64
)

Jump to

Keyboard shortcuts

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