Created
July 11, 2024 16:42
-
-
Save b4nst/9e9eff0e622982a82a672a20beb08e66 to your computer and use it in GitHub Desktop.
Go net foo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ( | |
"net" | |
"net/netip" | |
) | |
func PrefixToIPNet(p netip.Prefix) net.IPNet { | |
ip := p.Masked().Addr().AsSlice() | |
return net.IPNet{ | |
IP: ip, | |
Mask: net.CIDRMask(p.Bits(), len(ip)*8), | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment