util/must: add Get2 for functions that return two values

Updates #cleanup

Signed-off-by: James Sanderson <jsanderson@tailscale.com>
This commit is contained in:
James Sanderson 2025-06-16 16:09:41 +01:00 committed by James 'zofrex' Sanderson
parent 3d6e1171c1
commit 735f15cb49

View File

@ -23,3 +23,11 @@ func Get[T any](v T, err error) T {
}
return v
}
// Get2 returns v1 and v2 as is. It panics if err is non-nil.
func Get2[T any, U any](v1 T, v2 U, err error) (T, U) {
if err != nil {
panic(err)
}
return v1, v2
}