-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change a UUID from []byte to [16]byte along with other API changes.
- Loading branch information
Showing
18 changed files
with
395 additions
and
353 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# How to contribute | ||
|
||
We definitely welcome patches and contribution to this project! | ||
|
||
### Legal requirements | ||
|
||
In order to protect both you and ourselves, you will need to sign the | ||
[Contributor License Agreement](https://cla.developers.google.com/clas). | ||
|
||
You may have already signed it for other Google projects. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
Paul Borman <borman@google.com> | ||
bmatsuo | ||
shawnps | ||
theory | ||
jboverfelt | ||
dsymonds | ||
cd1 | ||
wallclockbuilder | ||
dansouza |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
// Copyright 2011 Google Inc. All rights reserved. | ||
// Copyright 2016 Google Inc. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// The uuid package generates and inspects UUIDs. | ||
// Package uuid generates and inspects UUIDs. | ||
// | ||
// UUIDs are based on RFC 4122 and DCE 1.1: Authentication and Security Services. | ||
// UUIDs are based on RFC 4122 and DCE 1.1: Authentication and Security | ||
// Services. | ||
// | ||
// A UUID is a 16 byte (128 bit) array. UUIDs may be used as keys to | ||
// maps or compared directly. | ||
package uuid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2016 Google Inc. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package uuid | ||
|
||
import ( | ||
"fmt" | ||
"unsafe" | ||
) | ||
|
||
// MarshalText implements encoding.TextMarshaler. | ||
func (u UUID) MarshalText() ([]byte, error) { | ||
var js [36]byte | ||
encodeHex(js[:], u) | ||
return js[:], nil | ||
} | ||
|
||
// UnmarshalText implements encoding.TextUnmarshaler. | ||
func (u *UUID) UnmarshalText(data []byte) error { | ||
// See comment in ParseBytes why we do this. | ||
// id, err := ParseBytes(data) | ||
id, err := Parse(*(*string)(unsafe.Pointer(&data))) | ||
if err == nil { | ||
*u = id | ||
} | ||
return err | ||
} | ||
|
||
// MarshalBinary implements encoding.BinaryMarshaler. | ||
func (u UUID) MarshalBinary() ([]byte, error) { | ||
return u[:], nil | ||
} | ||
|
||
// UnmarshalBinary implements encoding.BinaryUnmarshaler. | ||
func (u *UUID) UnmarshalBinary(data []byte) error { | ||
if len(data) != 16 { | ||
return fmt.Errorf("invalid UUID (got %d bytes)", len(data)) | ||
} | ||
copy(u[:], data) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.