units

package
v0.0.0-...-03ea0d3 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2022 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

View Source
const Zero = ID("0")

Zero defines the zero id constant assigned to the ignored unit.

Variables

This section is empty.

Functions

func Set

func Set(d *Units)

Types

type ID

type ID string

ID defines the id of a unit.

type Unit

type Unit struct {
	ID      ID     // unit id
	Name    string // unit name
	Display string // unit display name
	VName   string // variable uniquely associated with this unit
}

Unit defines the unit schema with the relevant fields.

func NewUnit

func NewUnit(id ID, name, display, vname string) *Unit

New creates a new unit.

type Units

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

func DefaultCatalog

func DefaultCatalog() *Units

DefaultCatalog defines variable units and their aliases.

func Get

func Get() *Units

func Load

func Load(fname string) (*Units, error)

Load loads units from a file.​

func New

func New() *Units

func (*Units) Add

func (us *Units) Add(id ID, name string, display string, aliases []string, vname string) error

func (*Units) Get

func (us *Units) Get(candidate string) (string, bool)

Match returns true if the candidate is in the unit catalog.

func (*Units) ID

func (us *Units) ID(name string) (ID, bool)

ID returns the ID of the variable name.

func (*Units) Match

func (us *Units) Match(candidate string) bool

Match returns true if the candidate is in the unit catalog.

func (*Units) Size

func (us *Units) Size() int

func (*Units) Unit

func (us *Units) Unit(id ID) *Unit

Variable returns the variable associated with the variable id.

func (*Units) Variable

func (us *Units) Variable(name string) (string, bool)

Jump to

Keyboard shortcuts

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