Skip to content

Commit 386c6cc

Browse files
committed
Add MustParse
1 parent f4b3e66 commit 386c6cc

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

cid.go

+9
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,15 @@ func Parse(v interface{}) (Cid, error) {
181181
}
182182
}
183183

184+
// MustParse calls Parse but will panic on error.
185+
func MustParse(v interface{}) Cid {
186+
c, err := Parse(v)
187+
if err != nil {
188+
panic(err)
189+
}
190+
return c
191+
}
192+
184193
// Decode parses a Cid-encoded string and returns a Cid object.
185194
// For CidV1, a Cid-encoded string is primarily a multibase string:
186195
//

0 commit comments

Comments
 (0)