diff --git a/op/op.go b/op/op.go index 09e2a86..9486f49 100644 --- a/op/op.go +++ b/op/op.go @@ -166,12 +166,19 @@ func Assert(cond bool, msgs ...any) { if !cond { msg := "assertion failed" if len(msgs) > 0 { - msg += ": " + fmt.Sprint(msgs) + msg = fmt.Sprint(msgs) } panic(msg) } } +// Assertf panics with a formatted message if cond is false. +func Assertf(cond bool, format string, args ...any) { + if !cond { + panic(fmt.Sprintf(format, args...)) + } +} + // ReverseCompare returns a comparison function that reverses the order of the original comparison function. func ReverseCompare[T any](cmp func(T, T) int) func(T, T) int { return func(x, y T) int {