Created
December 28, 2023 21:32
-
-
Save tarcisio/4598ba9f17639951fdde76a3eb68437c to your computer and use it in GitHub Desktop.
Generics Must
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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