ids

package
v0.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 3, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package ids hosts typed wrappers for cross-service entity IDs.

Passing typed IDs across boundaries makes it impossible to mistakenly swap a UserID for an OrgID — the compiler stops it. The wrapper embeds uuid.UUID so all the standard machinery (JSON marshalling, database/sql scanning, .String()) is inherited automatically and validation is real UUID parsing rather than a regex.

Add types as your domain grows. The pattern is uniform: a struct wrapping uuid.UUID, a New<Name> constructor for fresh IDs, and a Parse<Name> that delegates to uuid.Parse.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OrgID

type OrgID struct{ uuid.UUID }

OrgID is a typed identifier for an organization.

func NewOrgID

func NewOrgID() OrgID

NewOrgID returns a fresh, random OrgID (UUID v4).

func ParseOrgID

func ParseOrgID(s string) (OrgID, error)

ParseOrgID parses s as a UUID and returns it as an OrgID.

type UserID

type UserID struct{ uuid.UUID }

UserID is a typed identifier for a user.

func NewUserID

func NewUserID() UserID

NewUserID returns a fresh, random UserID (UUID v4).

func ParseUserID

func ParseUserID(s string) (UserID, error)

ParseUserID parses s as a UUID and returns it as a UserID. The underlying uuid.Parse handles canonical, URN, and braced forms; invalid input returns the zero UserID plus uuid's error.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL