gonum: gonum.org/v1/gonum/unit Index | Examples | Files

package unit

import "gonum.org/v1/gonum/unit"

Package unit provides a set of types and constants that facilitate the use of the International System of Units (SI).

The unit package provides two main functionalities: compile-time type-safe base SI units and common derived units; and a system for dynamically extensible user-defined units.

Static SI units

This package provides a number of types representing either an SI base unit or a common combination of base units, named for the physical quantity it represents (Length, Mass, Pressure, etc.). Each type is defined from float64. The value of the float64 represents the quantity of that unit as expressed in SI base units (Kilogram, Meter, Pascal, etc.). For example,

height := 1.6 * unit.Meter
acc := unit.Acceleration(9.8)

creates a variable named 'height' with a value of 1.6 meters, and a variable named 'acc' with a value of 9.8 meters per second squared. These types can be used to add compile-time safety to code. For example,

func unitVolume(t unit.Temperature, p unit.Pressure) unit.Volume {
	...
}

func main(){
	t := 300 * unit.Kelvin
	p := 500 * unit.Kilopascal
	v := unitVolume(p, t) // compile-time error
}

gives a compile-time error (temperature type does not match pressure type) while the corresponding code using float64 runs without error.

func float64Volume(temperature, pressure float64) float64 {
	...
}

func main(){
	t := 300.0 // Kelvin
	p := 500000.0 // Pascals
	v := float64Volume(p, t) // no error
}

Many types have constants defined representing named SI units (Meter, Kilogram, etc. ) or SI derived units (Pascal, Hz, etc.). The unit package additionally provides untyped constants for SI prefixes, so the following are all equivalent.

l := 0.001 * unit.Meter
k := 1 * unit.Milli * unit.Meter
j := unit.Length(0.001)

Additional SI-derived static units can also be defined by adding types that satisfy the Uniter interface described below.

Dynamic user-extensible unit system

The unit package also provides the Unit type, a representation of a general dimensional value. Unit can be used to help prevent errors of dimensionality when multiplying or dividing dimensional numbers defined a run time. New variables of type Unit can be created with the New function and the Dimensions map. For example, the code

rate := unit.New(1 * unit.Milli, Dimensions{MoleDim: 1, TimeDim: -1})

creates a variable "rate" which has a value of 1e-3 mol/s. Methods of unit can be used to modify this value, for example:

rate.Mul(1 * unit.Centimeter).Div(1 * unit.Millivolt)

To convert the unit back into a typed float64 value, the From methods of the dimensional types should be used. From will return an error if the dimensions do not match.

var energy unit.Energy
err := energy.From(acc)

Domain-specific problems may need custom dimensions, and for this purpose NewDimension should be used to help avoid accidental overlap between packages. For example, results from a blood test may be measured in "White blood cells per slide". In this case, NewDimension should be used to create a 'WhiteBloodCell' dimension. NewDimension takes in a string which will be used for printing that dimension, and will return a unique dimension number.

wbc := unit.NewDimension("WhiteBloodCell")

NewDimension should not be used, however, to create the unit of 'Slide', because in this case slide is just a measurement of liquid volume. Instead, a constant could be defined.

const Slide unit.Volume =  0.1 * unit.Microliter

Note that unit cannot catch all errors related to dimensionality. Different physical ideas are sometimes expressed with the same dimensions and unit is incapable of catching these mismatches. For example, energy and torque are both expressed as force times distance (Newton-meters in SI), but it is wrong to say that a torque of 10 N-m is the same as 10 J, even though the dimensions agree. Despite this, using the defined types to represent units can help to catch errors at compile-time. For example,

type Torque float64

func (t Torque) Unit() *Unit {...

allows you to define a statically typed function like so

func LeverLength(apply unit.Force, want Torque) unit.Length {
	return unit.Length(float64(want)/float64(apply))
}

This will prevent an energy value being provided to LeverLength in place of a torque value.

Code:

// One mechanical horsepower ≡ 33,000 ft-lbf/min.
foot := unit.Length(0.3048)
pound := unit.Mass(0.45359237)

gravity := unit.Acceleration(9.80665)
poundforce := pound.Unit().Mul(gravity)

hp := ((33000 * foot).Unit().Mul(poundforce)).Div(unit.Minute)
fmt.Println("1 hp =", hp)

watt := unit.Power(1)
fmt.Println("W is equivalent to hp?", unit.DimensionsMatch(hp, watt))

Output:

1 hp = 745.6998715822701 kg m^2 s^-3
W is equivalent to hp? true

Index

Examples

Package Files

absorbedradioactivedose.go acceleration.go angle.go area.go capacitance.go charge.go conductance.go consts.go current.go dimless.go doc.go energy.go equivalentradioactivedose.go force.go frequency.go inductance.go length.go luminousintensity.go magneticflux.go magneticfluxdensity.go mass.go mole.go power.go pressure.go radioactivity.go resistance.go temperature.go time.go unittype.go velocity.go voltage.go volume.go

Constants

const (
    Yotta = 1e24
    Zetta = 1e21
    Exa   = 1e18
    Peta  = 1e15
    Tera  = 1e12
    Giga  = 1e9
    Mega  = 1e6
    Kilo  = 1e3
    Hecto = 1e2
    Deca  = 1e1

    Deci  = 1e-1
    Centi = 1e-2
    Milli = 1e-3
    Micro = 1e-6
    Nano  = 1e-9
    Pico  = 1e-12
    Femto = 1e-15
    Atto  = 1e-18
    Zepto = 1e-21
    Yocto = 1e-24
)

func DimensionsMatch Uses

func DimensionsMatch(a, b Uniter) bool

DimensionsMatch checks if the dimensions of two Uniters are the same.

func SymbolExists Uses

func SymbolExists(symbol string) bool

SymbolExists returns whether the given symbol is already in use.

type AbsorbedRadioactiveDose Uses

type AbsorbedRadioactiveDose float64

AbsorbedRadioactiveDose is a measure of absorbed dose of ionizing radiation in grays.

const (
    Yottagray AbsorbedRadioactiveDose = 1e24
    Zettagray AbsorbedRadioactiveDose = 1e21
    Exagray   AbsorbedRadioactiveDose = 1e18
    Petagray  AbsorbedRadioactiveDose = 1e15
    Teragray  AbsorbedRadioactiveDose = 1e12
    Gigagray  AbsorbedRadioactiveDose = 1e9
    Megagray  AbsorbedRadioactiveDose = 1e6
    Kilogray  AbsorbedRadioactiveDose = 1e3
    Hectogray AbsorbedRadioactiveDose = 1e2
    Decagray  AbsorbedRadioactiveDose = 1e1
    Gray      AbsorbedRadioactiveDose = 1.0
    Decigray  AbsorbedRadioactiveDose = 1e-1
    Centigray AbsorbedRadioactiveDose = 1e-2
    Milligray AbsorbedRadioactiveDose = 1e-3
    Microgray AbsorbedRadioactiveDose = 1e-6
    Nanogray  AbsorbedRadioactiveDose = 1e-9
    Picogray  AbsorbedRadioactiveDose = 1e-12
    Femtogray AbsorbedRadioactiveDose = 1e-15
    Attogray  AbsorbedRadioactiveDose = 1e-18
    Zeptogray AbsorbedRadioactiveDose = 1e-21
    Yoctogray AbsorbedRadioactiveDose = 1e-24
)

func (AbsorbedRadioactiveDose) AbsorbedRadioactiveDose Uses

func (a AbsorbedRadioactiveDose) AbsorbedRadioactiveDose() AbsorbedRadioactiveDose

AbsorbedRadioactiveDose allows AbsorbedRadioactiveDose to implement a AbsorbedRadioactiveDoseer interface

func (AbsorbedRadioactiveDose) Format Uses

func (a AbsorbedRadioactiveDose) Format(fs fmt.State, c rune)

func (*AbsorbedRadioactiveDose) From Uses

func (a *AbsorbedRadioactiveDose) From(u Uniter) error

From converts the unit into the receiver. From returns an error if there is a mismatch in dimension

func (AbsorbedRadioactiveDose) Unit Uses

func (a AbsorbedRadioactiveDose) Unit() *Unit

Unit converts the AbsorbedRadioactiveDose to a *Unit

type Acceleration Uses

type Acceleration float64

Acceleration represents an acceleration in meters per second squared.

func (Acceleration) Acceleration Uses

func (a Acceleration) Acceleration() Acceleration

Acceleration allows Acceleration to implement a Accelerationer interface

func (Acceleration) Format Uses

func (a Acceleration) Format(fs fmt.State, c rune)

func (*Acceleration) From Uses

func (a *Acceleration) From(u Uniter) error

From converts the unit into the receiver. From returns an error if there is a mismatch in dimension

func (Acceleration) Unit Uses

func (a Acceleration) Unit() *Unit

Unit converts the Acceleration to a *Unit

type Angle Uses

type Angle float64

Angle represents an angle in radians.

const (
    Yottarad Angle = 1e24
    Zettarad Angle = 1e21
    Exarad   Angle = 1e18
    Petarad  Angle = 1e15
    Terarad  Angle = 1e12
    Gigarad  Angle = 1e9
    Megarad  Angle = 1e6
    Kilorad  Angle = 1e3
    Hectorad Angle = 1e2
    Decarad  Angle = 1e1
    Rad      Angle = 1.0
    Decirad  Angle = 1e-1
    Centirad Angle = 1e-2
    Millirad Angle = 1e-3
    Microrad Angle = 1e-6
    Nanorad  Angle = 1e-9
    Picorad  Angle = 1e-12
    Femtorad Angle = 1e-15
    Attorad  Angle = 1e-18
    Zeptorad Angle = 1e-21
    Yoctorad Angle = 1e-24
)

func (Angle) Angle Uses

func (a Angle) Angle() Angle

Angle allows Angle to implement a Angleer interface

func (Angle) Format Uses

func (a Angle) Format(fs fmt.State, c rune)

func (*Angle) From Uses

func (a *Angle) From(u Uniter) error

From converts the unit into the receiver. From returns an error if there is a mismatch in dimension

func (Angle) Unit Uses

func (a Angle) Unit() *Unit

Unit converts the Angle to a *Unit

type Area Uses

type Area float64

Area represents and area in square meters.

func (Area) Area Uses

func (a Area) Area() Area

Area allows Area to implement a Areaer interface

func (Area) Format Uses

func (a Area) Format(fs fmt.State, c rune)

func (*Area) From Uses

func (a *Area) From(u Uniter) error

From converts the unit into the receiver. From returns an error if there is a mismatch in dimension

func (Area) Unit Uses

func (a Area) Unit() *Unit

Unit converts the Area to a *Unit

type Capacitance Uses

type Capacitance float64

Capacitance represents an electrical capacitance in Farads.

const (
    Yottafarad Capacitance = 1e24
    Zettafarad Capacitance = 1e21
    Exafarad   Capacitance = 1e18
    Petafarad  Capacitance = 1e15
    Terafarad  Capacitance = 1e12
    Gigafarad  Capacitance = 1e9
    Megafarad  Capacitance = 1e6
    Kilofarad  Capacitance = 1e3
    Hectofarad Capacitance = 1e2
    Decafarad  Capacitance = 1e1
    Farad      Capacitance = 1.0
    Decifarad  Capacitance = 1e-1
    Centifarad Capacitance = 1e-2
    Millifarad Capacitance = 1e-3
    Microfarad Capacitance = 1e-6
    Nanofarad  Capacitance = 1e-9
    Picofarad  Capacitance = 1e-12
    Femtofarad Capacitance = 1e-15
    Attofarad  Capacitance = 1e-18
    Zeptofarad Capacitance = 1e-21
    Yoctofarad Capacitance = 1e-24
)

func (Capacitance) Capacitance Uses

func (cp Capacitance) Capacitance() Capacitance

Capacitance allows Capacitance to implement a Capacitancer interface

func (Capacitance) Format Uses

func (cp Capacitance) Format(fs fmt.State, c rune)

func (*Capacitance) From Uses

func (cp *Capacitance) From(u Uniter) error

From converts the unit into the receiver. From returns an error if there is a mismatch in dimension

func (Capacitance) Unit Uses

func (cp Capacitance) Unit() *Unit

Unit converts the Capacitance to a *Unit

type Charge Uses

type Charge float64

Charge represents an electric charge in Coulombs.

const (
    Yottacoulomb Charge = 1e24
    Zettacoulomb Charge = 1e21
    Exacoulomb   Charge = 1e18
    Petacoulomb  Charge = 1e15
    Teracoulomb  Charge = 1e12
    Gigacoulomb  Charge = 1e9
    Megacoulomb  Charge = 1e6
    Kilocoulomb  Charge = 1e3
    Hectocoulomb Charge = 1e2
    Decacoulomb  Charge = 1e1

    Decicoulomb  Charge = 1e-1
    Centicoulomb Charge = 1e-2
    Millicoulomb Charge = 1e-3
    Microcoulomb Charge = 1e-6
    Nanocoulomb  Charge = 1e-9
    Picocoulomb  Charge = 1e-12
    Femtocoulomb Charge = 1e-15
    Attocoulomb  Charge = 1e-18
    Zeptocoulomb Charge = 1e-21
    Yoctocoulomb Charge = 1e-24
)

func (Charge) Charge Uses

func (ch Charge) Charge() Charge

Charge allows Charge to implement a Charger interface

func (Charge) Format Uses

func (ch Charge) Format(fs fmt.State, c rune)

func (*Charge) From Uses

func (ch *Charge) From(u Uniter) error

From converts the unit into the receiver. From returns an error if there is a mismatch in dimension

func (Charge) Unit Uses

func (ch Charge) Unit() *Unit

Unit converts the Charge to a *Unit

type Conductance Uses

type Conductance float64

Conductance represents an electrical conductance in Siemens.

const (
    Yottasiemens Conductance = 1e24
    Zettasiemens Conductance = 1e21
    Exasiemens   Conductance = 1e18
    Petasiemens  Conductance = 1e15
    Terasiemens  Conductance = 1e12
    Gigasiemens  Conductance = 1e9
    Megasiemens  Conductance = 1e6
    Kilosiemens  Conductance = 1e3
    Hectosiemens Conductance = 1e2
    Decasiemens  Conductance = 1e1
    Siemens      Conductance = 1.0
    Decisiemens  Conductance = 1e-1
    Centisiemens Conductance = 1e-2
    Millisiemens Conductance = 1e-3
    Microsiemens Conductance = 1e-6
    Nanosiemens  Conductance = 1e-9
    Picosiemens  Conductance = 1e-12
    Femtosiemens Conductance = 1e-15
    Attosiemens  Conductance = 1e-18
    Zeptosiemens Conductance = 1e-21
    Yoctosiemens Conductance = 1e-24
)

func (Conductance) Conductance Uses

func (co Conductance) Conductance() Conductance

Conductance allows Conductance to implement a Conductancer interface

func (Conductance) Format Uses

func (co Conductance) Format(fs fmt.State, c rune)

func (*Conductance) From Uses

func (co *Conductance) From(u Uniter) error

From converts the unit into the receiver. From returns an error if there is a mismatch in dimension

func (Conductance) Unit Uses

func (co Conductance) Unit() *Unit

Unit converts the Conductance to a *Unit

type Current Uses

type Current float64

Current represents a current in Amperes.

const (
    Yottaampere Current = 1e24
    Zettaampere Current = 1e21
    Exaampere   Current = 1e18
    Petaampere  Current = 1e15
    Teraampere  Current = 1e12
    Gigaampere  Current = 1e9
    Megaampere  Current = 1e6
    Kiloampere  Current = 1e3
    Hectoampere Current = 1e2
    Decaampere  Current = 1e1
    Ampere      Current = 1.0
    Deciampere  Current = 1e-1
    Centiampere Current = 1e-2
    Milliampere Current = 1e-3
    Microampere Current = 1e-6
    Nanoampere  Current = 1e-9
    Picoampere  Current = 1e-12
    Femtoampere Current = 1e-15
    Attoampere  Current = 1e-18
    Zeptoampere Current = 1e-21
    Yoctoampere Current = 1e-24
)

func (Current) Current Uses

func (i Current) Current() Current

Current allows Current to implement a Currenter interface

func (Current) Format Uses

func (i Current) Format(fs fmt.State, c rune)

func (*Current) From Uses

func (i *Current) From(u Uniter) error

From converts the unit into the receiver. From returns an error if there is a mismatch in dimension

func (Current) Unit Uses

func (i Current) Unit() *Unit

Unit converts the Current to a *Unit

type Dimension Uses

type Dimension int

Dimension is a type representing an SI base dimension or a distinct orthogonal dimension. Non-SI dimensions can be created using the NewDimension function, typically within an init function.

const (
    CurrentDim Dimension
    LengthDim
    LuminousIntensityDim
    MassDim
    MoleDim
    TemperatureDim
    TimeDim
    // Other common SI Dimensions
    AngleDim // e.g. radians
)

func NewDimension Uses

func NewDimension(symbol string) Dimension

NewDimension creates a new orthogonal dimension with the given symbol, and returns the value of that dimension. The input symbol must not overlap with any of the any of the SI base units or other symbols of common use in SI ("kg", "J", etc.), and must not overlap with any other dimensions created by calls to NewDimension. The SymbolExists function can check if the symbol exists. NewDimension will panic if the input symbol matches an existing symbol.

NewDimension should only be called for unit types that are actually orthogonal to the base dimensions defined in this package. See the package-level documentation for further explanation.

Code:

// Create a "trees" dimension
// Typically, this should be used within an init function
treeDim := unit.NewDimension("tree")
countPerArea := unit.New(0.1, unit.Dimensions{treeDim: 1, unit.LengthDim: -2})
fmt.Println(countPerArea)

Output:

0.1 tree m^-2

func (Dimension) String Uses

func (d Dimension) String() string

String returns the string for the dimension.

type Dimensions Uses

type Dimensions map[Dimension]int

Dimensions represent the dimensionality of the unit in powers of that dimension. If a key is not present, the power of that dimension is zero. Dimensions is used in conjunction with New.

func (Dimensions) String Uses

func (d Dimensions) String() string

type Dimless Uses

type Dimless float64

Dimless represents a dimensionless constant

const (
    One Dimless = 1.0
)

func (Dimless) Dimless Uses

func (d Dimless) Dimless() Dimless

Dimless allows Dimless to implement a Dimlesser interface

func (Dimless) Format Uses

func (d Dimless) Format(fs fmt.State, c rune)

func (*Dimless) From Uses

func (d *Dimless) From(u *Unit) error

From converts the unit to a dimless. Returns an error if there is a mismatch in dimension

func (Dimless) Unit Uses

func (d Dimless) Unit() *Unit

Unit converts the Dimless to a unit

type Energy Uses

type Energy float64

Energy represents a quantity of energy in Joules.

const (
    Yottajoule Energy = 1e24
    Zettajoule Energy = 1e21
    Exajoule   Energy = 1e18
    Petajoule  Energy = 1e15
    Terajoule  Energy = 1e12
    Gigajoule  Energy = 1e9
    Megajoule  Energy = 1e6
    Kilojoule  Energy = 1e3
    Hectojoule Energy = 1e2
    Decajoule  Energy = 1e1
    Joule      Energy = 1.0
    Decijoule  Energy = 1e-1
    Centijoule Energy = 1e-2
    Millijoule Energy = 1e-3
    Microjoule Energy = 1e-6
    Nanojoule  Energy = 1e-9
    Picojoule  Energy = 1e-12
    Femtojoule Energy = 1e-15
    Attojoule  Energy = 1e-18
    Zeptojoule Energy = 1e-21
    Yoctojoule Energy = 1e-24
)

func (Energy) Energy Uses

func (e Energy) Energy() Energy

Energy allows Energy to implement a Energyer interface

func (Energy) Format Uses

func (e Energy) Format(fs fmt.State, c rune)

func (*Energy) From Uses

func (e *Energy) From(u Uniter) error

From converts the unit into the receiver. From returns an error if there is a mismatch in dimension

func (Energy) Unit Uses

func (e Energy) Unit() *Unit

Unit converts the Energy to a *Unit

type EquivalentRadioactiveDose Uses

type EquivalentRadioactiveDose float64

EquivalentRadioactiveDose is a measure of equivalent dose of ionizing radiation in sieverts.

const (
    Yottasievert EquivalentRadioactiveDose = 1e24
    Zettasievert EquivalentRadioactiveDose = 1e21
    Exasievert   EquivalentRadioactiveDose = 1e18
    Petasievert  EquivalentRadioactiveDose = 1e15
    Terasievert  EquivalentRadioactiveDose = 1e12
    Gigasievert  EquivalentRadioactiveDose = 1e9
    Megasievert  EquivalentRadioactiveDose = 1e6
    Kilosievert  EquivalentRadioactiveDose = 1e3
    Hectosievert EquivalentRadioactiveDose = 1e2
    Decasievert  EquivalentRadioactiveDose = 1e1
    Sievert      EquivalentRadioactiveDose = 1.0
    Decisievert  EquivalentRadioactiveDose = 1e-1
    Centisievert EquivalentRadioactiveDose = 1e-2
    Millisievert EquivalentRadioactiveDose = 1e-3
    Microsievert EquivalentRadioactiveDose = 1e-6
    Nanosievert  EquivalentRadioactiveDose = 1e-9
    Picosievert  EquivalentRadioactiveDose = 1e-12
    Femtosievert EquivalentRadioactiveDose = 1e-15
    Attosievert  EquivalentRadioactiveDose = 1e-18
    Zeptosievert EquivalentRadioactiveDose = 1e-21
    Yoctosievert EquivalentRadioactiveDose = 1e-24
)

func (EquivalentRadioactiveDose) EquivalentRadioactiveDose Uses

func (a EquivalentRadioactiveDose) EquivalentRadioactiveDose() EquivalentRadioactiveDose

EquivalentRadioactiveDose allows EquivalentRadioactiveDose to implement a EquivalentRadioactiveDoseer interface

func (EquivalentRadioactiveDose) Format Uses

func (a EquivalentRadioactiveDose) Format(fs fmt.State, c rune)

func (*EquivalentRadioactiveDose) From Uses

func (a *EquivalentRadioactiveDose) From(u Uniter) error

From converts the unit into the receiver. From returns an error if there is a mismatch in dimension

func (EquivalentRadioactiveDose) Unit Uses

func (a EquivalentRadioactiveDose) Unit() *Unit

Unit converts the EquivalentRadioactiveDose to a *Unit

type Force Uses

type Force float64

Force represents a force in Newtons.

const (
    Yottanewton Force = 1e24
    Zettanewton Force = 1e21
    Exanewton   Force = 1e18
    Petanewton  Force = 1e15
    Teranewton  Force = 1e12
    Giganewton  Force = 1e9
    Meganewton  Force = 1e6
    Kilonewton  Force = 1e3
    Hectonewton Force = 1e2
    Decanewton  Force = 1e1
    Newton      Force = 1.0
    Decinewton  Force = 1e-1
    Centinewton Force = 1e-2
    Millinewton Force = 1e-3
    Micronewton Force = 1e-6
    Nanonewton  Force = 1e-9
    Piconewton  Force = 1e-12
    Femtonewton Force = 1e-15
    Attonewton  Force = 1e-18
    Zeptonewton Force = 1e-21
    Yoctonewton Force = 1e-24
)

func (Force) Force Uses

func (f Force) Force() Force

Force allows Force to implement a Forcer interface

func (Force) Format Uses

func (f Force) Format(fs fmt.State, c rune)

func (*Force) From Uses

func (f *Force) From(u Uniter) error

From converts the unit into the receiver. From returns an error if there is a mismatch in dimension

func (Force) Unit Uses

func (f Force) Unit() *Unit

Unit converts the Force to a *Unit

type Frequency Uses

type Frequency float64

Frequency represents a frequency in Hertz.

const (
    Yottahertz Frequency = 1e24
    Zettahertz Frequency = 1e21
    Exahertz   Frequency = 1e18
    Petahertz  Frequency = 1e15
    Terahertz  Frequency = 1e12
    Gigahertz  Frequency = 1e9
    Megahertz  Frequency = 1e6
    Kilohertz  Frequency = 1e3
    Hectohertz Frequency = 1e2
    Decahertz  Frequency = 1e1
    Hertz      Frequency = 1.0
    Decihertz  Frequency = 1e-1
    Centihertz Frequency = 1e-2
    Millihertz Frequency = 1e-3
    Microhertz Frequency = 1e-6
    Nanohertz  Frequency = 1e-9
    Picohertz  Frequency = 1e-12
    Femtohertz Frequency = 1e-15
    Attohertz  Frequency = 1e-18
    Zeptohertz Frequency = 1e-21
    Yoctohertz Frequency = 1e-24
)

func (Frequency) Format Uses

func (f Frequency) Format(fs fmt.State, c rune)

func (Frequency) Frequency Uses

func (f Frequency) Frequency() Frequency

Frequency allows Frequency to implement a Frequencyer interface

func (*Frequency) From Uses

func (f *Frequency) From(u Uniter) error

From converts the unit into the receiver. From returns an error if there is a mismatch in dimension

func (Frequency) Unit Uses

func (f Frequency) Unit() *Unit

Unit converts the Frequency to a *Unit

type Inductance Uses

type Inductance float64

Inductance represents an electrical inductance in Henry.

const (
    Yottahenry Inductance = 1e24
    Zettahenry Inductance = 1e21
    Exahenry   Inductance = 1e18
    Petahenry  Inductance = 1e15
    Terahenry  Inductance = 1e12
    Gigahenry  Inductance = 1e9
    Megahenry  Inductance = 1e6
    Kilohenry  Inductance = 1e3
    Hectohenry Inductance = 1e2
    Decahenry  Inductance = 1e1
    Henry      Inductance = 1.0
    Decihenry  Inductance = 1e-1
    Centihenry Inductance = 1e-2
    Millihenry Inductance = 1e-3
    Microhenry Inductance = 1e-6
    Nanohenry  Inductance = 1e-9
    Picohenry  Inductance = 1e-12
    Femtohenry Inductance = 1e-15
    Attohenry  Inductance = 1e-18
    Zeptohenry Inductance = 1e-21
    Yoctohenry Inductance = 1e-24
)

func (Inductance) Format Uses

func (i Inductance) Format(fs fmt.State, c rune)

func (*Inductance) From Uses

func (i *Inductance) From(u Uniter) error

From converts the unit into the receiver. From returns an error if there is a mismatch in dimension

func (Inductance) Inductance Uses

func (i Inductance) Inductance() Inductance

Inductance allows Inductance to implement a Inductancer interface

func (Inductance) Unit Uses

func (i Inductance) Unit() *Unit

Unit converts the Inductance to a *Unit

type Length Uses

type Length float64

Length represents a length in meters.

const (
    Yottameter Length = 1e24
    Zettameter Length = 1e21
    Exameter   Length = 1e18
    Petameter  Length = 1e15
    Terameter  Length = 1e12
    Gigameter  Length = 1e9
    Megameter  Length = 1e6
    Kilometer  Length = 1e3
    Hectometer Length = 1e2
    Decameter  Length = 1e1
    Meter      Length = 1.0
    Decimeter  Length = 1e-1
    Centimeter Length = 1e-2
    Millimeter Length = 1e-3
    Micrometer Length = 1e-6
    Nanometer  Length = 1e-9
    Picometer  Length = 1e-12
    Femtometer Length = 1e-15
    Attometer  Length = 1e-18
    Zeptometer Length = 1e-21
    Yoctometer Length = 1e-24
)

func (Length) Format Uses

func (l Length) Format(fs fmt.State, c rune)

func (*Length) From Uses

func (l *Length) From(u Uniter) error

From converts the unit into the receiver. From returns an error if there is a mismatch in dimension

func (Length) Length Uses

func (l Length) Length() Length

Length allows Length to implement a Lengther interface

func (Length) Unit Uses

func (l Length) Unit() *Unit

Unit converts the Length to a *Unit

type LuminousIntensity Uses

type LuminousIntensity float64

Candela represents a luminous intensity in candela.

const (
    Yottacandela LuminousIntensity = 1e24
    Zettacandela LuminousIntensity = 1e21
    Exacandela   LuminousIntensity = 1e18
    Petacandela  LuminousIntensity = 1e15
    Teracandela  LuminousIntensity = 1e12
    Gigacandela  LuminousIntensity = 1e9
    Megacandela  LuminousIntensity = 1e6
    Kilocandela  LuminousIntensity = 1e3
    Hectocandela LuminousIntensity = 1e2
    Decacandela  LuminousIntensity = 1e1
    Candela      LuminousIntensity = 1.0
    Decicandela  LuminousIntensity = 1e-1
    Centicandela LuminousIntensity = 1e-2
    Millicandela LuminousIntensity = 1e-3
    Microcandela LuminousIntensity = 1e-6
    Nanocandela  LuminousIntensity = 1e-9
    Picocandela  LuminousIntensity = 1e-12
    Femtocandela LuminousIntensity = 1e-15
    Attocandela  LuminousIntensity = 1e-18
    Zeptocandela LuminousIntensity = 1e-21
    Yoctocandela LuminousIntensity = 1e-24
)

func (LuminousIntensity) Format Uses

func (j LuminousIntensity) Format(fs fmt.State, c rune)

func (*LuminousIntensity) From Uses

func (j *LuminousIntensity) From(u Uniter) error

From converts the unit into the receiver. From returns an error if there is a mismatch in dimension

func (LuminousIntensity) LuminousIntensity Uses

func (j LuminousIntensity) LuminousIntensity() LuminousIntensity

LuminousIntensity allows LuminousIntensity to implement a LuminousIntensityer interface

func (LuminousIntensity) Unit Uses

func (j LuminousIntensity) Unit() *Unit

Unit converts the LuminousIntensity to a *Unit

type MagneticFlux Uses

type MagneticFlux float64

MagneticFlux represents a magnetic flux in Weber.

const (
    Yottaweber MagneticFlux = 1e24
    Zettaweber MagneticFlux = 1e21
    Exaweber   MagneticFlux = 1e18
    Petaweber  MagneticFlux = 1e15
    Teraweber  MagneticFlux = 1e12
    Gigaweber  MagneticFlux = 1e9
    Megaweber  MagneticFlux = 1e6
    Kiloweber  MagneticFlux = 1e3
    Hectoweber MagneticFlux = 1e2
    Decaweber  MagneticFlux = 1e1
    Weber      MagneticFlux = 1.0
    Deciweber  MagneticFlux = 1e-1
    Centiweber MagneticFlux = 1e-2
    Milliweber MagneticFlux = 1e-3
    Microweber MagneticFlux = 1e-6
    Nanoweber  MagneticFlux = 1e-9
    Picoweber  MagneticFlux = 1e-12
    Femtoweber MagneticFlux = 1e-15
    Attoweber  MagneticFlux = 1e-18
    Zeptoweber MagneticFlux = 1e-21
    Yoctoweber MagneticFlux = 1e-24
)

func (MagneticFlux) Format Uses

func (m MagneticFlux) Format(fs fmt.State, c rune)

func (*MagneticFlux) From Uses

func (m *MagneticFlux) From(u Uniter) error

From converts the unit into the receiver. From returns an error if there is a mismatch in dimension

func (MagneticFlux) MagneticFlux Uses

func (m MagneticFlux) MagneticFlux() MagneticFlux

MagneticFlux allows MagneticFlux to implement a MagneticFluxer interface

func (MagneticFlux) Unit Uses

func (m MagneticFlux) Unit() *Unit

Unit converts the MagneticFlux to a *Unit

type MagneticFluxDensity Uses

type MagneticFluxDensity float64

MagneticFluxDensity represents a magnetic flux density in Tesla.

const (
    Yottatesla MagneticFluxDensity = 1e24
    Zettatesla MagneticFluxDensity = 1e21
    Exatesla   MagneticFluxDensity = 1e18
    Petatesla  MagneticFluxDensity = 1e15
    Teratesla  MagneticFluxDensity = 1e12
    Gigatesla  MagneticFluxDensity = 1e9
    Megatesla  MagneticFluxDensity = 1e6
    Kilotesla  MagneticFluxDensity = 1e3
    Hectotesla MagneticFluxDensity = 1e2
    Decatesla  MagneticFluxDensity = 1e1
    Tesla      MagneticFluxDensity = 1.0
    Decitesla  MagneticFluxDensity = 1e-1
    Centitesla MagneticFluxDensity = 1e-2
    Millitesla MagneticFluxDensity = 1e-3
    Microtesla MagneticFluxDensity = 1e-6
    Nanotesla  MagneticFluxDensity = 1e-9
    Picotesla  MagneticFluxDensity = 1e-12
    Femtotesla MagneticFluxDensity = 1e-15
    Attotesla  MagneticFluxDensity = 1e-18
    Zeptotesla MagneticFluxDensity = 1e-21
    Yoctotesla MagneticFluxDensity = 1e-24
)

func (MagneticFluxDensity) Format Uses

func (m MagneticFluxDensity) Format(fs fmt.State, c rune)

func (*MagneticFluxDensity) From Uses

func (m *MagneticFluxDensity) From(u Uniter) error

From converts the unit into the receiver. From returns an error if there is a mismatch in dimension

func (MagneticFluxDensity) MagneticFluxDensity Uses

func (m MagneticFluxDensity) MagneticFluxDensity() MagneticFluxDensity

MagneticFluxDensity allows MagneticFluxDensity to implement a MagneticFluxDensityer interface

func (MagneticFluxDensity) Unit Uses

func (m MagneticFluxDensity) Unit() *Unit

Unit converts the MagneticFluxDensity to a *Unit

type Mass Uses

type Mass float64

Mass represents a mass in kilograms.

const (
    Yottagram Mass = 1e21
    Zettagram Mass = 1e18
    Exagram   Mass = 1e15
    Petagram  Mass = 1e12
    Teragram  Mass = 1e9
    Gigagram  Mass = 1e6
    Megagram  Mass = 1e3
    Kilogram  Mass = 1.0
    Hectogram Mass = 1e-1
    Decagram  Mass = 1e-2
    Gram      Mass = 1e-3
    Decigram  Mass = 1e-4
    Centigram Mass = 1e-5
    Milligram Mass = 1e-6
    Microgram Mass = 1e-9
    Nanogram  Mass = 1e-12
    Picogram  Mass = 1e-15
    Femtogram Mass = 1e-18
    Attogram  Mass = 1e-21
    Zeptogram Mass = 1e-24
    Yoctogram Mass = 1e-27
)

func (Mass) Format Uses

func (m Mass) Format(fs fmt.State, c rune)

func (*Mass) From Uses

func (m *Mass) From(u Uniter) error

From converts the unit into the receiver. From returns an error if there is a mismatch in dimension

func (Mass) Mass Uses

func (m Mass) Mass() Mass

Mass allows Mass to implement a Masser interface

func (Mass) Unit Uses

func (m Mass) Unit() *Unit

Unit converts the Mass to a *Unit

type Mole Uses

type Mole float64

Mole represents an amount in moles.

const (
    Yottamol Mole = 1e24
    Zettamol Mole = 1e21
    Examol   Mole = 1e18
    Petamol  Mole = 1e15
    Teramol  Mole = 1e12
    Gigamol  Mole = 1e9
    Megamol  Mole = 1e6
    Kilomol  Mole = 1e3
    Hectomol Mole = 1e2
    Decamol  Mole = 1e1

    Decimol  Mole = 1e-1
    Centimol Mole = 1e-2
    Millimol Mole = 1e-3
    Micromol Mole = 1e-6
    Nanomol  Mole = 1e-9
    Picomol  Mole = 1e-12
    Femtomol Mole = 1e-15
    Attomol  Mole = 1e-18
    Zeptomol Mole = 1e-21
    Yoctomol Mole = 1e-24
)

func (Mole) Format Uses

func (n Mole) Format(fs fmt.State, c rune)

func (*Mole) From Uses

func (n *Mole) From(u Uniter) error

From converts the unit into the receiver. From returns an error if there is a mismatch in dimension

func (Mole) Mole Uses

func (n Mole) Mole() Mole

Mole allows Mole to implement a Moleer interface

func (Mole) Unit Uses

func (n Mole) Unit() *Unit

Unit converts the Mole to a *Unit

type Power Uses

type Power float64

Power represents a power in Watts.

const (
    Yottawatt Power = 1e24
    Zettawatt Power = 1e21
    Exawatt   Power = 1e18
    Petawatt  Power = 1e15
    Terawatt  Power = 1e12
    Gigawatt  Power = 1e9
    Megawatt  Power = 1e6
    Kilowatt  Power = 1e3
    Hectowatt Power = 1e2
    Decawatt  Power = 1e1
    Watt      Power = 1.0
    Deciwatt  Power = 1e-1
    Centiwatt Power = 1e-2
    Milliwatt Power = 1e-3
    Microwatt Power = 1e-6
    Nanowatt  Power = 1e-9
    Picowatt  Power = 1e-12
    Femtowatt Power = 1e-15
    Attowatt  Power = 1e-18
    Zeptowatt Power = 1e-21
    Yoctowatt Power = 1e-24
)

func (Power) Format Uses

func (pw Power) Format(fs fmt.State, c rune)

func (*Power) From Uses

func (pw *Power) From(u Uniter) error

From converts the unit into the receiver. From returns an error if there is a mismatch in dimension

func (Power) Power Uses

func (pw Power) Power() Power

Power allows Power to implement a Powerer interface

func (Power) Unit Uses

func (pw Power) Unit() *Unit

Unit converts the Power to a *Unit

type Pressure Uses

type Pressure float64

Pressure represents a pressure in Pascals.

const (
    Yottapascal Pressure = 1e24
    Zettapascal Pressure = 1e21
    Exapascal   Pressure = 1e18
    Petapascal  Pressure = 1e15
    Terapascal  Pressure = 1e12
    Gigapascal  Pressure = 1e9
    Megapascal  Pressure = 1e6
    Kilopascal  Pressure = 1e3
    Hectopascal Pressure = 1e2
    Decapascal  Pressure = 1e1
    Pascal      Pressure = 1.0
    Decipascal  Pressure = 1e-1
    Centipascal Pressure = 1e-2
    Millipascal Pressure = 1e-3
    Micropascal Pressure = 1e-6
    Nanopascal  Pressure = 1e-9
    Picopascal  Pressure = 1e-12
    Femtopascal Pressure = 1e-15
    Attopascal  Pressure = 1e-18
    Zeptopascal Pressure = 1e-21
    Yoctopascal Pressure = 1e-24
)

func (Pressure) Format Uses

func (pr Pressure) Format(fs fmt.State, c rune)

func (*Pressure) From Uses

func (pr *Pressure) From(u Uniter) error

From converts the unit into the receiver. From returns an error if there is a mismatch in dimension

func (Pressure) Pressure Uses

func (pr Pressure) Pressure() Pressure

Pressure allows Pressure to implement a Pressurer interface

func (Pressure) Unit Uses

func (pr Pressure) Unit() *Unit

Unit converts the Pressure to a *Unit

type Radioactivity Uses

type Radioactivity float64

Radioactivity represents a rate of radioactive decay in becquerels.

const (
    Yottabecquerel Radioactivity = 1e24
    Zettabecquerel Radioactivity = 1e21
    Exabecquerel   Radioactivity = 1e18
    Petabecquerel  Radioactivity = 1e15
    Terabecquerel  Radioactivity = 1e12
    Gigabecquerel  Radioactivity = 1e9
    Megabecquerel  Radioactivity = 1e6
    Kilobecquerel  Radioactivity = 1e3
    Hectobecquerel Radioactivity = 1e2
    Decabecquerel  Radioactivity = 1e1
    Becquerel      Radioactivity = 1.0
    Decibecquerel  Radioactivity = 1e-1
    Centibecquerel Radioactivity = 1e-2
    Millibecquerel Radioactivity = 1e-3
    Microbecquerel Radioactivity = 1e-6
    Nanobecquerel  Radioactivity = 1e-9
    Picobecquerel  Radioactivity = 1e-12
    Femtobecquerel Radioactivity = 1e-15
    Attobecquerel  Radioactivity = 1e-18
    Zeptobecquerel Radioactivity = 1e-21
    Yoctobecquerel Radioactivity = 1e-24
)

func (Radioactivity) Format Uses

func (r Radioactivity) Format(fs fmt.State, c rune)

func (*Radioactivity) From Uses

func (r *Radioactivity) From(u Uniter) error

From converts the unit into the receiver. From returns an error if there is a mismatch in dimension

func (Radioactivity) Radioactivity Uses

func (r Radioactivity) Radioactivity() Radioactivity

Radioactivity allows Radioactivity to implement a Radioactivityer interface

func (Radioactivity) Unit Uses

func (r Radioactivity) Unit() *Unit

Unit converts the Radioactivity to a *Unit

type Resistance Uses

type Resistance float64

Resistance represents an electrical resistance, impedance or reactance in Ohms.

const (
    Yottaohm Resistance = 1e24
    Zettaohm Resistance = 1e21
    Exaohm   Resistance = 1e18
    Petaohm  Resistance = 1e15
    Teraohm  Resistance = 1e12
    Gigaohm  Resistance = 1e9
    Megaohm  Resistance = 1e6
    Kiloohm  Resistance = 1e3
    Hectoohm Resistance = 1e2
    Decaohm  Resistance = 1e1
    Ohm      Resistance = 1.0
    Deciohm  Resistance = 1e-1
    Centiohm Resistance = 1e-2
    Milliohm Resistance = 1e-3
    Microohm Resistance = 1e-6
    Nanoohm  Resistance = 1e-9
    Picoohm  Resistance = 1e-12
    Femtoohm Resistance = 1e-15
    Attoohm  Resistance = 1e-18
    Zeptoohm Resistance = 1e-21
    Yoctoohm Resistance = 1e-24
)

func (Resistance) Format Uses

func (r Resistance) Format(fs fmt.State, c rune)

func (*Resistance) From Uses

func (r *Resistance) From(u Uniter) error

From converts the unit into the receiver. From returns an error if there is a mismatch in dimension

func (Resistance) Resistance Uses

func (r Resistance) Resistance() Resistance

Resistance allows Resistance to implement a Resistancer interface

func (Resistance) Unit Uses

func (r Resistance) Unit() *Unit

Unit converts the Resistance to a *Unit

type Temperature Uses

type Temperature float64

Temperature represents a temperature in Kelvin.

const (
    Yottakelvin Temperature = 1e24
    Zettakelvin Temperature = 1e21
    Exakelvin   Temperature = 1e18
    Petakelvin  Temperature = 1e15
    Terakelvin  Temperature = 1e12
    Gigakelvin  Temperature = 1e9
    Megakelvin  Temperature = 1e6
    Kilokelvin  Temperature = 1e3
    Hectokelvin Temperature = 1e2
    Decakelvin  Temperature = 1e1
    Kelvin      Temperature = 1.0
    Decikelvin  Temperature = 1e-1
    Centikelvin Temperature = 1e-2
    Millikelvin Temperature = 1e-3
    Microkelvin Temperature = 1e-6
    Nanokelvin  Temperature = 1e-9
    Picokelvin  Temperature = 1e-12
    Femtokelvin Temperature = 1e-15
    Attokelvin  Temperature = 1e-18
    Zeptokelvin Temperature = 1e-21
    Yoctokelvin Temperature = 1e-24
)

func (Temperature) Format Uses

func (t Temperature) Format(fs fmt.State, c rune)

func (*Temperature) From Uses

func (t *Temperature) From(u Uniter) error

From converts the unit into the receiver. From returns an error if there is a mismatch in dimension

func (Temperature) Temperature Uses

func (t Temperature) Temperature() Temperature

Temperature allows Temperature to implement a Temperaturer interface

func (Temperature) Unit Uses

func (t Temperature) Unit() *Unit

Unit converts the Temperature to a *Unit

type Time Uses

type Time float64

Time represents a time in seconds.

const (
    Hour   Time = 3600
    Minute Time = 60

    Yottasecond Time = 1e24
    Zettasecond Time = 1e21
    Exasecond   Time = 1e18
    Petasecond  Time = 1e15
    Terasecond  Time = 1e12
    Gigasecond  Time = 1e9
    Megasecond  Time = 1e6
    Kilosecond  Time = 1e3
    Hectosecond Time = 1e2
    Decasecond  Time = 1e1
    Second      Time = 1.0
    Decisecond  Time = 1e-1
    Centisecond Time = 1e-2
    Millisecond Time = 1e-3
    Microsecond Time = 1e-6
    Nanosecond  Time = 1e-9
    Picosecond  Time = 1e-12
    Femtosecond Time = 1e-15
    Attosecond  Time = 1e-18
    Zeptosecond Time = 1e-21
    Yoctosecond Time = 1e-24
)

func (Time) Format Uses

func (t Time) Format(fs fmt.State, c rune)

func (*Time) From Uses

func (t *Time) From(u Uniter) error

From converts the unit into the receiver. From returns an error if there is a mismatch in dimension

func (Time) Time Uses

func (t Time) Time() Time

Time allows Time to implement a Timer interface

func (Time) Unit Uses

func (t Time) Unit() *Unit

Unit converts the Time to a *Unit

type Unit Uses

type Unit struct {
    // contains filtered or unexported fields
}

Unit represents a dimensional value. The dimensions will typically be in SI units, but can also include dimensions created with NewDimension. The Unit type is most useful for ensuring dimensional consistency when manipulating types with different units, for example, by multiplying an acceleration with a mass to get a force. See the package documentation for further explanation.

func New Uses

func New(value float64, d Dimensions) *Unit

New creates a new variable of type Unit which has the value and dimensions specified by the inputs. The built-in dimensions are always in SI units (meters, kilograms, etc.).

Code:

// Create an angular acceleration of 3 rad/s^2
accel := unit.New(3.0, unit.Dimensions{unit.AngleDim: 1, unit.TimeDim: -2})
fmt.Println(accel)

Output:

3 rad s^-2

func (*Unit) Add Uses

func (u *Unit) Add(uniter Uniter) *Unit

Add adds the function argument to the receiver. Panics if the units of the receiver and the argument don't match.

func (*Unit) Dimensions Uses

func (u *Unit) Dimensions() Dimensions

Dimensions returns a copy of the dimensions of the unit.

func (*Unit) Div Uses

func (u *Unit) Div(uniter Uniter) *Unit

Div divides the receiver by the argument changing the dimensions of the receiver as appropriate.

func (*Unit) Format Uses

func (u *Unit) Format(fs fmt.State, c rune)

Format makes Unit satisfy the fmt.Formatter interface. The unit is formatted with dimensions appended. If the power if the dimension is not zero or one, symbol^power is appended, if the power is one, just the symbol is appended and if the power is zero, nothing is appended. Dimensions are appended in order by symbol name with positive powers ahead of negative powers.

func (*Unit) Mul Uses

func (u *Unit) Mul(uniter Uniter) *Unit

Mul multiply the receiver by the input changing the dimensions of the receiver as appropriate. The input is not changed.

func (*Unit) SetValue Uses

func (u *Unit) SetValue(v float64)

SetValue sets the value of the unit.

func (*Unit) Unit Uses

func (u *Unit) Unit() *Unit

Unit implements the Uniter interface

func (*Unit) Value Uses

func (u *Unit) Value() float64

Value return the raw value of the unit as a float64. Use of this method is, in general, not recommended, though it can be useful for printing. Instead, the From method of a specific dimension should be used to guarantee dimension consistency.

type Uniter Uses

type Uniter interface {
    Unit() *Unit
}

Uniter is a type that can be converted to a Unit.

type Velocity Uses

type Velocity float64

Velocity represents a velocity in meters per second.

func (Velocity) Format Uses

func (v Velocity) Format(fs fmt.State, c rune)

func (*Velocity) From Uses

func (v *Velocity) From(u Uniter) error

From converts the unit into the receiver. From returns an error if there is a mismatch in dimension

func (Velocity) Unit Uses

func (v Velocity) Unit() *Unit

Unit converts the Velocity to a *Unit

func (Velocity) Velocity Uses

func (v Velocity) Velocity() Velocity

Velocity allows Velocity to implement a Velocityer interface

type Voltage Uses

type Voltage float64

Voltage represents a voltage in Volts.

const (
    Yottavolt Voltage = 1e24
    Zettavolt Voltage = 1e21
    Exavolt   Voltage = 1e18
    Petavolt  Voltage = 1e15
    Teravolt  Voltage = 1e12
    Gigavolt  Voltage = 1e9
    Megavolt  Voltage = 1e6
    Kilovolt  Voltage = 1e3
    Hectovolt Voltage = 1e2
    Decavolt  Voltage = 1e1
    Volt      Voltage = 1.0
    Decivolt  Voltage = 1e-1
    Centivolt Voltage = 1e-2
    Millivolt Voltage = 1e-3
    Microvolt Voltage = 1e-6
    Nanovolt  Voltage = 1e-9
    Picovolt  Voltage = 1e-12
    Femtovolt Voltage = 1e-15
    Attovolt  Voltage = 1e-18
    Zeptovolt Voltage = 1e-21
    Yoctovolt Voltage = 1e-24
)

func (Voltage) Format Uses

func (v Voltage) Format(fs fmt.State, c rune)

func (*Voltage) From Uses

func (v *Voltage) From(u Uniter) error

From converts the unit into the receiver. From returns an error if there is a mismatch in dimension

func (Voltage) Unit Uses

func (v Voltage) Unit() *Unit

Unit converts the Voltage to a *Unit

func (Voltage) Voltage Uses

func (v Voltage) Voltage() Voltage

Voltage allows Voltage to implement a Voltager interface

type Volume Uses

type Volume float64

Volume represents a volume in cubic meters.

const (
    Yottaliter Volume = 1e21
    Zettaliter Volume = 1e18
    Exaliter   Volume = 1e15
    Petaliter  Volume = 1e12
    Teraliter  Volume = 1e9
    Gigaliter  Volume = 1e6
    Megaliter  Volume = 1e3
    Kiloliter  Volume = 1.0
    Hectoliter Volume = 1e-1
    Decaliter  Volume = 1e-2
    Liter      Volume = 1e-3
    Deciliter  Volume = 1e-4
    Centiliter Volume = 1e-5
    Milliliter Volume = 1e-6
    Microliter Volume = 1e-9
    Nanoliter  Volume = 1e-12
    Picoliter  Volume = 1e-15
    Femtoliter Volume = 1e-18
    Attoliter  Volume = 1e-21
    Zeptoliter Volume = 1e-24
    Yoctoliter Volume = 1e-27
)

func (Volume) Format Uses

func (v Volume) Format(fs fmt.State, c rune)

func (*Volume) From Uses

func (v *Volume) From(u Uniter) error

From converts the unit into the receiver. From returns an error if there is a mismatch in dimension

func (Volume) Unit Uses

func (v Volume) Unit() *Unit

Unit converts the Volume to a *Unit

func (Volume) Volume Uses

func (v Volume) Volume() Volume

Volume allows Volume to implement a Volumeer interface

Package unit imports 7 packages (graph) and is imported by 2 packages. Updated 2019-03-23. Refresh now. Tools for package owners.