setup base entity and change cli to print actions

This commit is contained in:
Travis Shears 2025-09-30 11:09:27 +02:00
parent d1f4527b1b
commit b24cc4d427
6 changed files with 97 additions and 26 deletions

39
gemlog/core.go Normal file
View file

@ -0,0 +1,39 @@
package gemlog
import (
"crypto/rand"
"encoding/hex"
"fmt"
"time"
)
// GemlogEntry represents a single gemlog post entry
type GemlogEntry struct {
ID string `json:"id"`
Title string `json:"title"`
Slug string `json:"slug"`
Date time.Time `json:"date"`
Gemtxt string `json:"gemtxt"`
}
// 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
}

0
gemlog/db.go Normal file
View file

1
gemlog/write.go Normal file
View file

@ -0,0 +1 @@
package gemlog