hashable

package
v25.0.13+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package hashable provides handy utility types for making unhashable values hashable.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IPMAC

type IPMAC struct {
	// contains filtered or unexported fields
}

IPMAC is a hashable tuple of an IP address and a MAC address suitable for use as a map key.

func IPMACFrom

func IPMACFrom(ip netip.Addr, mac MACAddr) IPMAC

IPMACFrom returns an IPMAC with the provided IP and MAC addresses.

func (IPMAC) IP

func (i IPMAC) IP() netip.Addr

func (IPMAC) MAC

func (i IPMAC) MAC() MACAddr

func (IPMAC) String

func (i IPMAC) String() string

type MACAddr

type MACAddr uint64

MACAddr is a hashable encoding of a MAC address.

func MACAddrFrom6

func MACAddrFrom6(addr [6]byte) MACAddr

MACAddrFrom6 returns the address of the MAC-48 address given by the bytes in addr.

func MACAddrFromSlice

func MACAddrFromSlice(slice net.HardwareAddr) (MACAddr, bool)

MACAddrFromSlice parses the 6-byte slice as a MAC-48 address. Note that a net.HardwareAddr can be passed directly as the []byte argument. If slice's length is not 6, MACAddrFromSlice returns 0, false.

func ParseMAC

func ParseMAC(s string) (MACAddr, error)

ParseMAC parses s as an IEEE 802 MAC-48 address using one of the formats accepted by net.ParseMAC.

func (MACAddr) AsSlice

func (p MACAddr) AsSlice() []byte

AsSlice returns a MAC address in its 6-byte representation.

func (MACAddr) String

func (p MACAddr) String() string

String returns net.HardwareAddr(p.AsSlice()).String().

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL