Skip to content

Instantly share code, notes, and snippets.

@tarcisio
Created December 28, 2023 21:32
Show Gist options
  • Save tarcisio/4598ba9f17639951fdde76a3eb68437c to your computer and use it in GitHub Desktop.
Save tarcisio/4598ba9f17639951fdde76a3eb68437c to your computer and use it in GitHub Desktop.
Generics Must
package utils
func Must(err error) {
if err != nil {
panic(err)
}
}
func Must1[T any](v T, err error) T {
if err != nil {
panic(err)
}
return v
}
func Must2[T1, T2 any](v1 T1, v2 T2, err error) (T1, T2) {
if err != nil {
panic(err)
}
return v1, v2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment