Skip to content

Instantly share code, notes, and snippets.

@gglluukk
Forked from porjo/random_ip.go
Created November 15, 2023 23:04
Show Gist options
  • Select an option

  • Save gglluukk/b5b6d301af43f8197d0404d05f6a8815 to your computer and use it in GitHub Desktop.

Select an option

Save gglluukk/b5b6d301af43f8197d0404d05f6a8815 to your computer and use it in GitHub Desktop.

Revisions

  1. @porjo porjo created this gist Feb 11, 2019.
    21 changes: 21 additions & 0 deletions random_ip.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    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))
    }
    }