func CalculateSubnetIPs(cidr string, maxAddresses int) []string {
	var ips = []string{}
	ip, ipnet, err := net.ParseCIDR(cidr)
	if err != nil {
		return ips
	}
	for ip := ip.Mask(ipnet.Mask); ipnet.Contains(ip); inc(ip) {
		ips = append(ips, ip.String())
		if len(ips) > maxAddresses {
			return ips[1:]  
		}
	}
	if len(ips) > 1 {
		return ips[1 : len(ips)-1]
	}
	return ips
}
CalculateSubnetIPs will calculate a given maximum of addresses in the given cidr address space.
package lanscan
import "net"
import "strings"
var linkLocalCIDR = []string{
	"10.0.0.0/8",      
	"172.16.0.0/12",   
	"192.168.0.0/16",  
	"169.254.0.0/16",  
	"fc00::/7",        
	"fe80::/64"}       
var validNetworks = []string{"tcp", "tcp4", "tcp6", "udp", "udp4", "udp6", "ip", "ip4", "ip6", "unix", "unixgram", "unixpacket"}
func IsLinkLocalAddress(ip net.IP) bool {
	for _, curnet := range linkLocalCIDR {
		_, ipnet, err := net.ParseCIDR(curnet)
		if err != nil {
			return false
		}
		if !ip.IsLoopback() && ipnet.Contains(ip) {
			return true
		}
	}
	return false
}
func LinkLocalAddresses(network string) []string {
	var addrs = []string{}
	interfaces, err := net.Interfaces()
	if err != nil {
		return addrs
	}
	for _, i := range interfaces {
		addresses, _ := i.Addrs()
		for _, address := range addresses {
			ip, _, err := net.ParseCIDR(address.String())
			if err != nil {
				continue
			}
			if strings.Contains(network, "4") && ip.To4() == nil {
				continue
			}
			if strings.Contains(network, "6") && ip.To16() == nil {
				continue
			}
			if IsLinkLocalAddress(ip) {
				addrs = append(addrs, address.String())
			}
		}
	}
	return addrs
}