From 6634b3ff6bcdffbab38a049460ae6ea3cd68944f Mon Sep 17 00:00:00 2001 From: sam-anthony Date: Thu, 31 Mar 2022 20:27:39 -0230 Subject: refactor and compressor map image widget --- util/util.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 util/util.go (limited to 'util/util.go') diff --git a/util/util.go b/util/util.go new file mode 100644 index 0000000..5812ee1 --- /dev/null +++ b/util/util.go @@ -0,0 +1,31 @@ +package util + +import ( + "fmt" + "os" + + "github.com/sam-anthony/volute/mass" + "github.com/sam-anthony/volute/pressure" + "github.com/sam-anthony/volute/temperature" +) + +func Check(err error) { + if err != nil { + fmt.Println(err) + os.Exit(1) + } +} + +func Insert[T int32 | float32 | temperature.Temperature | pressure.Pressure | mass.FlowRate](slice []T, elem T, i int) []T { + return append( + slice[:i], + append( + []T{elem}, + slice[i:]..., + )..., + ) +} + +func Remove[T int32 | float32 | temperature.Temperature | pressure.Pressure | mass.FlowRate](slice []T, i int) []T { + return append(slice[:i], slice[i+1:]...) +} -- cgit v1.2.3