Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

Commit

Permalink
tag: add func MustNewKey to wrap NewKey with panic (#1141)
Browse files Browse the repository at this point in the history
  • Loading branch information
dolmen authored and rghetia committed May 29, 2019
1 parent 766cc5b commit 9c37759
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tag/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ func NewKey(name string) (Key, error) {
return Key{name: name}, nil
}

// MustNewKey creates or retrieves a string key identified by name.
// An invalid key name raises a panic.
func MustNewKey(name string) Key {
k, err := NewKey(name)
if err != nil {
panic(err)
}
return k
}

// Name returns the name of the key.
func (k Key) Name() string {
return k.name
Expand Down

0 comments on commit 9c37759

Please sign in to comment.