From f028bff042f471a68dff681af9c79ef96bc952e5 Mon Sep 17 00:00:00 2001 From: Keuin Date: Fri, 9 Sep 2022 02:30:19 +0800 Subject: Fix file buffer does not take effect. No idea why golang's io utility is so suck. Use ad-hoc buffered copy loop instead. --- common/minmax.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 common/minmax.go (limited to 'common/minmax.go') diff --git a/common/minmax.go b/common/minmax.go new file mode 100644 index 0000000..b670887 --- /dev/null +++ b/common/minmax.go @@ -0,0 +1,27 @@ +package common + +/* +Golang is a piece of shit. Its creators are paranoids. +*/ + +import ( + "golang.org/x/exp/constraints" +) + +type Number interface { + constraints.Integer | constraints.Float +} + +func Min[T Number](t1 T, t2 T) T { + if t1 < t2 { + return t1 + } + return t2 +} + +func Max[T Number](t1 T, t2 T) T { + if t1 > t2 { + return t1 + } + return t2 +} -- cgit v1.2.3