func linkLocalUnicastAddr(ip net.IP) bool {
	return ip.IsLinkLocalUnicast()
}
linkLocalUnicastAddr matches link-local unicast addresses.
package ndp
import (
	"fmt"
	"net"
)
type Addr string
const (
	Unspecified Addr = "unspecified"
	LinkLocal   Addr = "linklocal"
	UniqueLocal Addr = "uniquelocal"
	Global      Addr = "global"
)
func chooseAddr(addrs []net.Addr, zone string, addr Addr) (*net.IPAddr, error) {
	if addr == Unspecified {
		return &net.IPAddr{
			IP:   net.IPv6unspecified,
			Zone: zone,
		}, nil
	}
	var match func(ip net.IP) bool
	switch addr {
	case LinkLocal:
		match = linkLocalUnicastAddr
	case UniqueLocal:
		match = uniqueLocalUnicastAddr
	case Global:
		match = globalUnicastAddr
	default:
		ip := net.ParseIP(string(addr))
		if ip == nil {
			return nil, fmt.Errorf("ndp: invalid IPv6 address: %q", addr)
		}
		if err := checkIPv6(ip); err != nil {
			return nil, err
		}
		match = func(check net.IP) bool {
			return ip.Equal(check)
		}
	}
	return findAddr(addrs, addr, zone, match)
}
func findAddr(addrs []net.Addr, addr Addr, zone string, match func(ip net.IP) bool) (*net.IPAddr, error) {
	for _, a := range addrs {
		ipn, ok := a.(*net.IPNet)
		if !ok {
			continue
		}
		if err := checkIPv6(ipn.IP); err != nil {
			continue
		}
		if match(ipn.IP) {
			return &net.IPAddr{
				IP:   ipn.IP,
				Zone: zone,
			}, nil
		}
	}
	return nil, fmt.Errorf("ndp: address %q not found on interface %q", addr, zone)
}