Documentation ¶
Overview ¶
Package nutrition provides food nutrition information
Index ¶
Constants ¶
View Source
const USDAProvider = "U.S. Department of Agriculture"
USDAProvider indicates the source is the USDA
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Fetcher ¶
type Fetcher interface { Lookup(query string) ([]*ItemResponse, error) Fetch([]string) (*Response, error) }
Fetcher outlines methods to get nutrition info for a food
type ItemResponse ¶
type ItemResponse struct { Name string `json:"name"` NDBNO string `json:"ndbno"` Manufacturer string `json:"manu"` }
ItemResponse is a lookup item response
type Measure ¶
type Measure struct { Label string Equivalent float64 Units string Quantity float64 Value json.Number }
Measure is an alternative measurement
type Nutrient ¶
type Nutrient struct { ID json.Number Name string Unit string Value json.Number Measures []Measure }
Nutrient is a single nutrient
type Response ¶
type Response struct { Foods []Food Provider provider }
Response is a nutrition response
type USDA ¶
USDA retrieves nutrition information from the USDA API
type USDALookupResponse ¶
type USDALookupResponse struct { List struct { Q string `json:"q"` Sr string `json:"sr"` Ds string `json:"ds"` Start int `json:"start"` End int `json:"end"` Total int `json:"total"` Group string `json:"group"` Sort string `json:"sort"` Item []struct { Offset int `json:"offset"` Group string `json:"group"` Name string `json:"name"` NDBNO string `json:"ndbno"` Ds string `json:"ds"` Manufacturer string `json:"manu"` } `json:"item"` } `json:"list"` }
USDALookupResponse is the response from USDA
type USDAMeasure ¶
type USDAMeasure struct { Label string `json:"label"` Eqv float64 `json:"eqv"` Eunit string `json:"eunit"` Qty float64 `json:"qty"` Value json.Number `json:"value"` }
USDAMeasure is an individual size
type USDAResponse ¶
type USDAResponse struct { Foods []struct { Food struct { Sr string `json:"sr"` Type string `json:"type"` Desc struct { Ndbno string `json:"ndbno"` Name string `json:"name"` Sd string `json:"sd"` Fg string `json:"fg"` Sn string `json:"sn"` Cn string `json:"cn"` Manu string `json:"manu"` Nf float64 `json:"nf"` Cf float64 `json:"cf"` Ff float64 `json:"ff"` Pf float64 `json:"pf"` R string `json:"r"` Rd string `json:"rd"` Ds string `json:"ds"` Ru string `json:"ru"` } `json:"desc"` Nutrients []struct { NutrientID json.Number `json:"nutrient_id"` // sometimes it's a string, sometimes a number Name string `json:"name"` Group string `json:"group"` Unit string `json:"unit"` Value json.Number `json:"value"` Derivation string `json:"derivation"` Sourcecode interface{} `json:"sourcecode"` Dp json.Number `json:"dp"` // sometimes it's a string, sometimes a number Se string `json:"se"` Measures []USDAMeasure `json:"measures"` } `json:"nutrients"` Sources []struct { ID int `json:"id"` Title string `json:"title"` Authors string `json:"authors"` Vol string `json:"vol"` Iss string `json:"iss"` Year string `json:"year"` } `json:"sources"` Footnotes []interface{} `json:"footnotes"` Langual []interface{} `json:"langual"` } `json:"food"` } `json:"foods"` Count int `json:"count"` Notfound int `json:"notfound"` API float64 `json:"api"` }
USDAResponse is the response from USDA
Click to show internal directories.
Click to hide internal directories.