I did two functions, one that expects imperial units (Go America!) and one that expects metric units (the rest of the world!).
body.go
packagebodyconst(underweightstring="Underweight"normalstring="Normal"overweightstring="Overweight"obesestring="Obese")// Attributes represents some properties of a person's physique, such as weight and heighttypeAttributesstruct{Heightfloat64Weightfloat64}// BMI gives a description of your body health based on your attributes using body mass indexfuncBMI(attrAttributes)string{returnstatus((attr.Weight/(attr.Height*attr.Height))*703)}// BMIMetric serves the same purpose as BMI but expects the attributes to be in the metric scale (kilograms, meters)funcBMIMetric(attrAttributes)string{returnstatus(attr.Weight/(attr.Height*attr.Height))}funcstatus(bmifloat64)string{switch{casebmi<=18.5:returnunderweightcasebmi<=25.0:returnnormalcasebmi<=30.0:returnoverweightdefault:returnobese}}
I did two functions, one that expects imperial units (Go America!) and one that expects metric units (the rest of the world!).
body.go
body_test.go