Skip to content

Commit

Permalink
Add IsNil() method.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevina committed Aug 29, 2018
1 parent 290e737 commit 193039c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cid.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,17 @@ func NewCidV1(codecType uint64, mhash mh.Multihash) Cid {
// - hash mh.Multihash
type Cid struct{ str string }

// Nil can be used to represent a nil Cid, using Cid{} directly is
// also acceptable.
var Nil = Cid{}

// Nil returns true if a Cid is uninitialized or the Nil value.
// Calling any other methods on an uninitialized Cid will result in
// undefined behavior.
func (c Cid) IsNil() bool {
return c.str == ""
}

// Parse is a short-hand function to perform Decode, Cast etc... on
// a generic interface{} type.
func Parse(v interface{}) (Cid, error) {
Expand Down

0 comments on commit 193039c

Please sign in to comment.