Skip to content

Commit

Permalink
Fix UnmarshalJSON
Browse files Browse the repository at this point in the history
  • Loading branch information
vmihailenco committed Aug 7, 2019
1 parent ae432a0 commit 3d2bb72
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions uuid.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@ func (u UUID) MarshalJSON() ([]byte, error) {
var _ json.Unmarshaler = (*UUID)(nil)

func (u *UUID) UnmarshalJSON(b []byte) error {
if len(b) != uuidHexLen+2 {
return fmt.Errorf("sharding: invalid UUID: %q", b)
if len(b) >= 2 {
b = b[1 : len(b)-1]
}
return u.UnmarshalText(b[1 : len(b)-1])
return u.UnmarshalText(b)
}

func unixMicrosecond(tm time.Time) int64 {
Expand Down

0 comments on commit 3d2bb72

Please sign in to comment.