Files
Raj Chaudhuri df2240acbd Some vulnerable dependencies upgraded
* golang.org/x/net to v0.8.0
* golang.org/x/crypto to v0.0.0-20220314234659-1baeb1ce4c0b
* github.com/aws/aws-sdk-go to v1.34.0
* github.com/prometheus/client_golang to v1.14.0
* k8s.io/client-go to v0.23.0
2023-03-28 11:44:24 +05:30

39 lines
907 B
Go

// 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"
// MarshalText implements encoding.TextMarshaler.
func (uuid UUID) MarshalText() ([]byte, error) {
var js [36]byte
encodeHex(js[:], uuid)
return js[:], nil
}
// UnmarshalText implements encoding.TextUnmarshaler.
func (uuid *UUID) UnmarshalText(data []byte) error {
id, err := ParseBytes(data)
if err != nil {
return err
}
*uuid = id
return nil
}
// MarshalBinary implements encoding.BinaryMarshaler.
func (uuid UUID) MarshalBinary() ([]byte, error) {
return uuid[:], nil
}
// UnmarshalBinary implements encoding.BinaryUnmarshaler.
func (uuid *UUID) UnmarshalBinary(data []byte) error {
if len(data) != 16 {
return fmt.Errorf("invalid UUID (got %d bytes)", len(data))
}
copy(uuid[:], data)
return nil
}