Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewUUIDv7 ¶
func NewUUIDv7() string
NewUUIDv7 generates a time-ordered UUIDv7 string for database primary keys.
UUIDv7 provides:
- Time-ordered sortability for better database index performance
- Compatibility with both PostgreSQL and SQLite (no gen_random_uuid() dependency)
- Monotonic ordering within the same millisecond
This function panics if UUID generation fails, which only occurs on catastrophic system failures (e.g., entropy source exhaustion). This is acceptable because:
- UUID generation failure means the system cannot operate safely
- All database ID generation would fail anyway
- Explicit error handling adds complexity without practical benefit
Use this for all model ID fields instead of uuid.NewString() (UUIDv4).
Types ¶
type DatabaseType ¶
type DatabaseType string
DatabaseType represents the type of database
const ( DatabaseTypePostgreSQL DatabaseType = "postgres" DatabaseTypeSQLite DatabaseType = "sqlite" )
func DetectDatabaseType ¶
func DetectDatabaseType(dsn string) DatabaseType
DetectDatabaseType determines the database type from a DSN string
Click to show internal directories.
Click to hide internal directories.