package gemlog import ( "crypto/rand" "encoding/hex" "fmt" "time" ) // GemlogEntry represents a single gemlog post entry type GemlogEntry struct { Title string `json:"title"` Slug string `json:"slug"` Date time.Time `json:"date"` Tags []string `json:"tags"` Gemtxt string `json:"gemtxt"` } type GemlogListEntry struct { Title string `json:"title"` Slug string `json:"slug"` Date time.Time `json:"date"` ID string `json:"id"` Rev string `json:"rev"` } // NewUUID generates a new UUID v4 using crypto/rand func NewUUID() (string, error) { uuid := make([]byte, 16) _, err := rand.Read(uuid) if err != nil { return "", fmt.Errorf("failed to generate UUID: %w", err) } // Set version (4) and variant bits according to RFC 4122 uuid[6] = (uuid[6] & 0x0f) | 0x40 // Version 4 uuid[8] = (uuid[8] & 0x3f) | 0x80 // Variant bits // Format as standard UUID string: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx return fmt.Sprintf("%s-%s-%s-%s-%s", hex.EncodeToString(uuid[0:4]), hex.EncodeToString(uuid[4:6]), hex.EncodeToString(uuid[6:8]), hex.EncodeToString(uuid[8:10]), hex.EncodeToString(uuid[10:16]), ), nil }