Skip to content

Commit

Permalink
add Must2()
Browse files Browse the repository at this point in the history
  • Loading branch information
kjk committed Aug 20, 2023
1 parent f928e5d commit 2886b73
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/kjk/common

go 1.16
go 1.18

require (
github.com/andybalholm/brotli v1.0.5
Expand Down
7 changes: 7 additions & 0 deletions u/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ func Must(err error) {
}
}

func Must2[T any](x T, err error) T {

Check failure on line 15 in u/base.go

View workflow job for this annotation

GitHub Actions / Build

missing function body

Check failure on line 15 in u/base.go

View workflow job for this annotation

GitHub Actions / Build

syntax error: unexpected [, expecting (

Check failure on line 15 in u/base.go

View workflow job for this annotation

GitHub Actions / Build

missing function body

Check failure on line 15 in u/base.go

View workflow job for this annotation

GitHub Actions / Build

syntax error: unexpected [, expecting (
if err != nil {
panic(err)
}
return x
}

func PanicIf(cond bool, args ...interface{}) {
if !cond {
return
Expand Down

0 comments on commit 2886b73

Please sign in to comment.