Skip to content

Commit 8f7d7ac

Browse files
authored
Merge pull request #139 from mg98/feat/must-parse
Add MustParse
2 parents b106e08 + 386c6cc commit 8f7d7ac

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

cid.go

Lines changed: 9 additions & 0 deletions
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)