all repos — vite @ 678fa38599dd50bf47e04e6440675b8e133b543c

a fast (this time, actually) and minimal static site generator

atom/uuid.go (view raw)

 1package atom
 2
 3import (
 4	"crypto/rand"
 5	"fmt"
 6)
 7
 8type UUID [16]byte
 9
10// Create a new uuid v4
11func NewUUID() *UUID {
12	u := &UUID{}
13	_, err := rand.Read(u[:16])
14	if err != nil {
15		panic(err)
16	}
17
18	u[8] = (u[8] | 0x80) & 0xBf
19	u[6] = (u[6] | 0x40) & 0x4f
20	return u
21}
22
23func (u *UUID) String() string {
24	return fmt.Sprintf("%x-%x-%x-%x-%x", u[:4], u[4:6], u[6:8], u[8:10], u[10:])
25}