Skip to content

Commit

Permalink
update the must functions
Browse files Browse the repository at this point in the history
  • Loading branch information
xgfone committed May 12, 2024
1 parent d5204d3 commit a2a8b30
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions cast_must.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,10 @@ func Must[T any](value T, err error) T {

// MustToTimeInLocation is the same as ToTimeInLocation, but panics if there is an error.
func MustToTimeInLocation(any interface{}, loc *time.Location, layouts ...string) time.Time {
v, err := ToTimeInLocation(any, loc, layouts...)
if err != nil {
panic(err)
}
return v
return Must(ToTimeInLocation(any, loc, layouts...))
}

// MustParseTime is the same as TryParseTime, but panics if there is an error.
func MustParseTime(value string, loc *time.Location, layouts ...string) time.Time {
v, err := TryParseTime(value, loc, layouts...)
if err != nil {
panic(err)
}
return v
return Must(TryParseTime(value, loc, layouts...))
}

0 comments on commit a2a8b30

Please sign in to comment.