1 // Copyright 2016 Google Inc. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
9 // MarshalText implements encoding.TextMarshaler.
10 func (uuid UUID) MarshalText() ([]byte, error) {
12 encodeHex(js[:], uuid)
16 // UnmarshalText implements encoding.TextUnmarshaler.
17 func (uuid *UUID) UnmarshalText(data []byte) error {
18 id, err := ParseBytes(data)
25 // MarshalBinary implements encoding.BinaryMarshaler.
26 func (uuid UUID) MarshalBinary() ([]byte, error) {
30 // UnmarshalBinary implements encoding.BinaryUnmarshaler.
31 func (uuid *UUID) UnmarshalBinary(data []byte) error {
33 return fmt.Errorf("invalid UUID (got %d bytes)", len(data))