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

Commit 9c37759

Browse files
dolmenrghetia
authored andcommitted
tag: add func MustNewKey to wrap NewKey with panic (#1141)
1 parent 766cc5b commit 9c37759

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tag/key.go

+10
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ func NewKey(name string) (Key, error) {
2929
return Key{name: name}, nil
3030
}
3131

32+
// MustNewKey creates or retrieves a string key identified by name.
33+
// An invalid key name raises a panic.
34+
func MustNewKey(name string) Key {
35+
k, err := NewKey(name)
36+
if err != nil {
37+
panic(err)
38+
}
39+
return k
40+
}
41+
3242
// Name returns the name of the key.
3343
func (k Key) Name() string {
3444
return k.name

0 commit comments

Comments
 (0)