day325

package
v0.0.0-...-36687a4 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2020 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrConversionImpossible

func ErrConversionImpossible() error

ErrConversionImpossible returns the error given when a conversion isn't possible.

Types

type Converter

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

Converter knows how to convert from/to different units of measure.

func NewConverter

func NewConverter() *Converter

NewConverter returns a pointer to a new Converter.

func (*Converter) AddConversion

func (c *Converter) AddConversion(factor float64, from, to Unit)

AddConversion adds a new conversion rule to the table in both directions.

func (*Converter) Convert

func (c *Converter) Convert(val float64, from, to Unit) (float64, error)

Convert attempts to convert a value from one unit to another. Uses a DFS algorithm to find a path to that conversion.

type Unit

type Unit string

Unit represents a unit of measure.

Jump to

Keyboard shortcuts

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