M go.mod => go.mod +1 -1
@@ 1,6 1,6 @@
module git.sr.ht/~ogham/doom
-go 1.16
+go 1.18
require (
github.com/getsentry/sentry-go v0.13.0
M phttpc/http.go => phttpc/http.go +6 -7
@@ 126,12 126,11 @@ func getJson(req *http.Request, endpoint *url.URL, target interface{}) {
}
}
-// Monomorphise checks the given length. Many responses should only include
-// arrays with a length of 0 (entity not found) or 1 (entity found); this
-// function checks for that not being the case.
-func Monomorphise(length int) {
- if length > 1 {
- panic(fmt.Sprintf("Too many elements (%d) in response", length))
+// Monomorphise checks the given list of results to have a length of 1. Many
+// responses should only include arrays with a length of 0 (entity not found) or
+// 1 (entity found); this function checks for that not being the case.
+func Monomorphise[T any](elements []T) {
+ if len(elements) > 1 {
+ panic(fmt.Sprintf("Too many elements (%d) in response: %+v", len(elements), elements))
}
}
-