Created
September 6, 2018 02:05
-
-
Save justnoise/1b5d7b2f5458a51c5f11e96fe4acc550 to your computer and use it in GitHub Desktop.
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
| func NetworkSize(cidr string) int { | |
| _, ipnet, err := net.ParseCIDR(cidr) | |
| if err != nil { | |
| return 0 | |
| } | |
| ones, bits := ipnet.Mask.Size() | |
| exp := uint(bits - ones) | |
| size := 1 << exp | |
| return size | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment