units

package
v1.0.14 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UnityMap = map[string]TypeUnity{
	"und": UnityUnit,
	"km":  UnityKilometer,
	"m":   UnityMeter,
	"cm":  UnityCentimeter,
	"mm":  UnityMillimeter,
	"mg":  UnityMiligram,
	"g":   UnityGram,
	"kg":  UnityKilogram,
	"t":   UnityTon,
	"lb":  UnityPound,
	"oz":  UnityOunce,
	"ml":  UnityMilliliter,
	"cl":  UnityCentiliter,
	"l":   UnityLiter,
	"m3":  UnityCubicMeter,
}

Functions

This section is empty.

Types

type Quantity

type Quantity struct {
	Value float64   `json:"value"`
	Unity TypeUnity `json:"unity"`
}

func Load

func Load(val any) (*Quantity, error)

* * Load * @param val any * @return *Quantity, error *

func NewQuantity

func NewQuantity(val float64, unit TypeUnity) *Quantity

* * NewQuantity * @param val float64, unit TypeUnity * @return *Quantity *

func (*Quantity) Load

func (s *Quantity) Load(val interface{}) error

* * Load * @param val interface{} *

func (*Quantity) To

func (s *Quantity) To(un TypeUnity) error

func (*Quantity) ToJson

func (s *Quantity) ToJson() et.Json

* * ToJson * @return et.Json *

func (*Quantity) ToStr

func (s *Quantity) ToStr() string

* * ToStr * @return string *

type TypeUnity

type TypeUnity int
const (
	UnityUnit TypeUnity = iota
	UnityKilometer
	UnityMeter
	UnityCentimeter
	UnityMillimeter
	UnityMiligram
	UnityGram
	UnityKilogram
	UnityTon
	UnityPound
	UnityOunce
	UnityMilliliter
	UnityCentiliter
	UnityLiter
	UnityCubicMeter
)

func StrToUnity

func StrToUnity(s string) TypeUnity

* * StrToUnity * @param s string * @return TypeUnity *

func (TypeUnity) Str

func (s TypeUnity) Str() string

* * Str * @return string *

Jump to

Keyboard shortcuts

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