Skip to content

Commit

Permalink
added MustString wrapper that panics for FromString
Browse files Browse the repository at this point in the history
  • Loading branch information
na4ma4 committed Nov 5, 2021
1 parent 9288879 commit 0d1497c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ const (
// ErrModeStringSyntax is returned when there is a syntax error in the mode string.
var ErrModeStringSyntax = errors.New("syntax error in mode string")

// MustString is a wrapper around FromString that will panic on invalid syntax.
func MustString(perms string) os.FileMode {
mode, err := FromString(perms)
if err != nil {
panic(err)
}

return mode
}

// FromString takes a subset of the available symbolic modes and returns a os.FileMode
// that is comprised of them or 0 and an error if the input is invalid.
//
Expand Down

0 comments on commit 0d1497c

Please sign in to comment.