1 // Copyright 2011 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.
8 guuid "github.com/google/uuid"
11 // NodeInterface returns the name of the interface from which the NodeID was
12 // derived. The interface "user" is returned if the NodeID was set by
14 func NodeInterface() string {
15 return guuid.NodeInterface()
18 // SetNodeInterface selects the hardware address to be used for Version 1 UUIDs.
19 // If name is "" then the first usable interface found will be used or a random
20 // Node ID will be generated. If a named interface cannot be found then false
23 // SetNodeInterface never fails when name is "".
24 func SetNodeInterface(name string) bool {
25 return guuid.SetNodeInterface(name)
28 // NodeID returns a slice of a copy of the current Node ID, setting the Node ID
29 // if not already set.
30 func NodeID() []byte {
34 // SetNodeID sets the Node ID to be used for Version 1 UUIDs. The first 6 bytes
35 // of id are used. If id is less than 6 bytes then false is returned and the
36 // Node ID is not set.
37 func SetNodeID(id []byte) bool {
38 return guuid.SetNodeID(id)
41 // NodeID returns the 6 byte node id encoded in uuid. It returns nil if uuid is
42 // not valid. The NodeID is only well defined for version 1 and 2 UUIDs.
43 func (uuid UUID) NodeID() []byte {
47 node := make([]byte, 6)