Created
March 23, 2024 00:29
-
-
Save ValentaTomas/cb7585c4c886a07f9f03eb4a2552c3fc to your computer and use it in GitHub Desktop.
Go utility for ensuring a proper value that panics otherwise
This file contains hidden or 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
func Must[T any](obj T, err error) T { | |
if err != nil { | |
panic(err) | |
} | |
return obj | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment