1
0
mirror of https://github.com/google/uuid.git synced 2025-02-20 12:33:21 +02:00

Merge pull request #7 from bmatsuo/bmatsuo/godoc-fixes

Misc godoc fixes
This commit is contained in:
pborman 2016-02-29 06:10:02 -08:00
commit dfce887783
4 changed files with 11 additions and 12 deletions

2
dce.go
View File

@ -61,7 +61,7 @@ func (uuid UUID) Domain() Domain {
return Domain(uuid[9]) return Domain(uuid[9])
} }
// Id returns the id for a Version 2 UUID. Ids are only defined for Vrsion 2 // Id returns the id for a Version 2 UUID. Ids are only defined for Version 2
// UUIDs. // UUIDs.
func (uuid UUID) Id() uint32 { func (uuid UUID) Id() uint32 {
return binary.BigEndian.Uint32(uuid[0:4]) return binary.BigEndian.Uint32(uuid[0:4])

View File

@ -10,33 +10,33 @@ import (
) )
// MarshalText implements encoding.TextMarshaler. // MarshalText implements encoding.TextMarshaler.
func (u UUID) MarshalText() ([]byte, error) { func (uuid UUID) MarshalText() ([]byte, error) {
var js [36]byte var js [36]byte
encodeHex(js[:], u) encodeHex(js[:], uuid)
return js[:], nil return js[:], nil
} }
// UnmarshalText implements encoding.TextUnmarshaler. // UnmarshalText implements encoding.TextUnmarshaler.
func (u *UUID) UnmarshalText(data []byte) error { func (uuid *UUID) UnmarshalText(data []byte) error {
// See comment in ParseBytes why we do this. // See comment in ParseBytes why we do this.
// id, err := ParseBytes(data) // id, err := ParseBytes(data)
id, err := Parse(*(*string)(unsafe.Pointer(&data))) id, err := Parse(*(*string)(unsafe.Pointer(&data)))
if err == nil { if err == nil {
*u = id *uuid = id
} }
return err return err
} }
// MarshalBinary implements encoding.BinaryMarshaler. // MarshalBinary implements encoding.BinaryMarshaler.
func (u UUID) MarshalBinary() ([]byte, error) { func (uuid UUID) MarshalBinary() ([]byte, error) {
return u[:], nil return uuid[:], nil
} }
// UnmarshalBinary implements encoding.BinaryUnmarshaler. // UnmarshalBinary implements encoding.BinaryUnmarshaler.
func (u *UUID) UnmarshalBinary(data []byte) error { func (uuid *UUID) UnmarshalBinary(data []byte) error {
if len(data) != 16 { if len(data) != 16 {
return fmt.Errorf("invalid UUID (got %d bytes)", len(data)) return fmt.Errorf("invalid UUID (got %d bytes)", len(data))
} }
copy(u[:], data) copy(uuid[:], data)
return nil return nil
} }

View File

@ -67,7 +67,7 @@ func Parse(s string) (UUID, error) {
return uuid, nil return uuid, nil
} }
// ParseBytes is like Parse, exect it parses a byte slice instead of a string. // ParseBytes is like Parse, except it parses a byte slice instead of a string.
func ParseBytes(b []byte) (UUID, error) { func ParseBytes(b []byte) (UUID, error) {
// Parsing a string is actually faster than parsing a byte slice as it // Parsing a string is actually faster than parsing a byte slice as it
// is cheaper to slice a string. Further, it is not safe to convert // is cheaper to slice a string. Further, it is not safe to convert
@ -129,7 +129,6 @@ func (uuid UUID) Variant() Variant {
} }
// Version returns the version of uuid. // Version returns the version of uuid.
// valid.
func (uuid UUID) Version() Version { func (uuid UUID) Version() Version {
return Version(uuid[6] >> 4) return Version(uuid[6] >> 4)
} }

View File

@ -13,7 +13,7 @@ import (
// or SetNodeInterface then it will be set automatically. If the NodeID cannot // or SetNodeInterface then it will be set automatically. If the NodeID cannot
// be set NewUUID returns nil. If clock sequence has not been set by // be set NewUUID returns nil. If clock sequence has not been set by
// SetClockSequence then it will be set automatically. If GetTime fails to // SetClockSequence then it will be set automatically. If GetTime fails to
// return the current NewUUID returns nil. // return the current NewUUID returns NIL and an error.
// //
// In most cases, New should be used. // In most cases, New should be used.
func NewUUID() (UUID, error) { func NewUUID() (UUID, error) {