Path: blob/main/vendor/github.com/google/uuid/node_net.go
2875 views
// Copyright 2017 Google Inc. All rights reserved.1// Use of this source code is governed by a BSD-style2// license that can be found in the LICENSE file.34// +build !js56package uuid78import "net"910var interfaces []net.Interface // cached list of interfaces1112// getHardwareInterface returns the name and hardware address of interface name.13// If name is "" then the name and hardware address of one of the system's14// interfaces is returned. If no interfaces are found (name does not exist or15// there are no interfaces) then "", nil is returned.16//17// Only addresses of at least 6 bytes are returned.18func getHardwareInterface(name string) (string, []byte) {19if interfaces == nil {20var err error21interfaces, err = net.Interfaces()22if err != nil {23return "", nil24}25}26for _, ifs := range interfaces {27if len(ifs.HardwareAddr) >= 6 && (name == "" || name == ifs.Name) {28return ifs.Name, ifs.HardwareAddr29}30}31return "", nil32}333435