Created
February 11, 2019 00:12
-
-
Save porjo/f1e6b79af77893ee71e857dfba2f8e9a to your computer and use it in GitHub Desktop.
Generate random IPs with Go
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
package main | |
import ( | |
"encoding/binary" | |
"fmt" | |
"math/rand" | |
"net" | |
) | |
func main() { | |
buf := make([]byte, 4) | |
for i := 0; i < 10; i++ { | |
ip := rand.Uint32() | |
binary.LittleEndian.PutUint32(buf, ip) | |
fmt.Printf("%s\n", net.IP(buf)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment