Documentation ¶
Index ¶
Constants ¶
const ( // ConversionFactorKGtoLBS is the weight of 1 KG in LBS ConversionFactorKGtoLBS float64 = 2.20462262185 )
Variables ¶
var ( // MensBarKG represents a standard men's 20 KG barbell MensBarKG = Bar{ Weight: 20.0, Unit: KG, } // MensBarLBS represents a standard men's 45 LBS barbell MensBarLBS = Bar{ Weight: 45.0, Unit: LBS, } // WomensBarKG represents a standard women's 15 KG barbell WomensBarKG = Bar{ Weight: 15.0, Unit: KG, } // WomensBarLBS represents a standard women's 35 LBS barbell WomensBarLBS = Bar{ Weight: 35.0, Unit: LBS, } )
var ( // DefaultGear is a map of default Gear structs DefaultGear = map[Unit]Gear{ LBS: { Bar: MensBarLBS, Plates: DefaultPlatesLBS, Unit: LBS, }, KG: { Bar: MensBarKG, Plates: DefaultPlatesKG, Unit: KG, }, } )
var DefaultPlatesKG = Plates{ Weights: DefaultWeightsKB, Unit: KG, }
DefaultPlatesKG is the default set of plates in KB
var DefaultPlatesLBS = Plates{ Weights: DefaultWeightsLBS, Unit: LBS, }
DefaultPlatesLBS is the default set of plates in LBS
var DefaultWeightsKB = []float64{
1.25,
2.5,
5,
10,
15,
20,
}
DefaultWeightsKB is the default set of weights in KB
var DefaultWeightsLBS = []float64{
2.5,
5,
10,
25,
35,
45,
}
DefaultWeightsLBS is the default set of weights in LBS
var ( // ErrInputLessThanBar is an error message used to warn that a Rounding call requests // a value that is less than the weight of the empty bar, itself. ErrInputLessThanBar = errors.New("input weight is less than the minimum weight of the bar") )
var ( // ErrInvalidUnit error are for any uint that is not represented by KG or LBS ErrInvalidUnit = errors.New("invalid unit") )
var ( // ErrNoPlatesFound is the basic error for not finding plates. ErrNoPlatesFound = errors.New("no plates found") )
Functions ¶
func ConvertFromTo ¶
ConvertFromTo takes a float64 and a from and to unit and converts the float into the requested unit. For instance if you wanted to convert 55 lbs to kg, Convert(55.0, LBS, KG) would return 24.9476, nil.
func FormFields ¶
FormFields returns an html snippet for choosing lifting gear for the submit form
Types ¶
type Bar ¶
Bar contains the weight and units of a Barbell
type Gear ¶
Gear is a struct that represents the weight inputs for the Bar, Plates, and desired unites for the Gear to be measured in. Gear is primary used to calculate possible weight totals from a requested weight amount, and is meant to be used to convert a lift from a calculated percentage into the greatest possible incremental weight with the equipment provided.
func FromValues ¶
FromValues takes a set of values in `url.Values` format and returns gear and an error.
func (Gear) Min ¶
Min returns the minimum amount allowed for rounding. This is based on the bar weight converted to the Gear Units.
type Plates ¶
Plates are are a set of plates and its corresponding unit.
type Unit ¶
type Unit uint
Unit is used to enumerate units for weights
func UnitFromString ¶
UnitFromString takes a string and returns a unit or error
func (Unit) MarshalJSON ¶
MarshalJSON is used for human readable json.
func (*Unit) UnmarshalJSON ¶
UnmarshalJSON is used to convert human readable json to a Unit type