-
-
Save gglluukk/b5b6d301af43f8197d0404d05f6a8815 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