uuid
3:1961288312a6 Browse Files
When given empty input, return an empty uuid. If we're given empty input while creating a UUID, we should return an empty UUID.
1.1 --- a/uuid.go Fri Jan 09 02:42:22 2015 -0500 1.2 +++ b/uuid.go Tue Jul 14 00:07:25 2015 -0400 1.3 @@ -40,6 +40,10 @@ 1.4 } 1.5 switch src.(type) { 1.6 case []byte: 1.7 + if len(src.([]byte)) == 0 { 1.8 + *id = (*id)[:0] 1.9 + return nil 1.10 + } 1.11 newID, err := Parse(string(src.([]byte))) 1.12 if err != nil { 1.13 return err 1.14 @@ -47,6 +51,10 @@ 1.15 *id = append((*id)[:0], newID...) 1.16 return nil 1.17 case string: 1.18 + if len(src.(string)) == 0 { 1.19 + *id = (*id)[:0] 1.20 + return nil 1.21 + } 1.22 newID, err := Parse(src.(string)) 1.23 if err != nil { 1.24 return err