aboutsummaryrefslogtreecommitdiffstats
path: root/mass.go
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2024-01-20 17:56:39 -0500
committerSam Anthony <sam@samanthony.xyz>2024-01-20 17:56:39 -0500
commit3aaae870ba76d8f0907b10a61d829ad353936306 (patch)
tree8be8cb950d0aa8039cd977c72e2f9438cae4a1e8 /mass.go
parentdb183cf7570e0f4e448ab5ced0ae41969261a815 (diff)
downloadvolute-3aaae870ba76d8f0907b10a61d829ad353936306.zip
flatten source directory structure by removing modules
Diffstat (limited to 'mass.go')
-rw-r--r--mass.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/mass.go b/mass.go
new file mode 100644
index 0000000..158bc37
--- /dev/null
+++ b/mass.go
@@ -0,0 +1,28 @@
+package main
+
+import (
+ "errors"
+ "fmt"
+)
+
+type MassFlowRate float32
+
+const (
+ KilogramsPerSecond MassFlowRate = 1
+ PoundsPerMinute MassFlowRate = 0.007_559_872_833
+)
+
+var MassFlowRateUnits = []string{"kg/s", "lb/min"}
+
+func ParseMassFlowRateUnit(s string) (MassFlowRate, error) {
+ // Each case corresponds to a value in MassFlowRateUnits.
+ switch s {
+ case "kg/s":
+ return KilogramsPerSecond, nil
+ case "lb/min":
+ return PoundsPerMinute, nil
+ default:
+ return *new(MassFlowRate), errors.New(
+ fmt.Sprintf("invalid mass flow rate unit: '%s'", s))
+ }
+}