I have code that looks like this:
u := make([]byte, 16) _, err := rand.Read(u) if err != nil { return } u[8] = (u[8] | 0x80) & 0xBF // what does thi
On Linux, you can read from /proc/sys/kernel/random/uuid:
/proc/sys/kernel/random/uuid
package main import "io/ioutil" import "fmt" func main() { u, _ := ioutil.ReadFile("/proc/sys/kernel/random/uuid") fmt.Println(string(u)) }
No external dependencies!
$ go run uuid.go 3ee995e3-0c96-4e30-ac1e-f7f04fd03e44