Help us shape the future of Go! Take the 2026 Go Developer Survey

shared

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package shared provides value types and normalization shared by subdomains.

Index

Constants

This section is empty.

Variables

View Source
var ErrDuplicateTag = errors.New("duplicate tag")

ErrDuplicateTag indicates a repeated normalized tag.

View Source
var ErrInvalidEntityMetadata = errors.New("invalid entity metadata")

ErrInvalidEntityMetadata identifies missing or nonchronological lifecycle times.

View Source
var ErrInvalidTag = errors.New("invalid tag")

ErrInvalidTag indicates an invalid tag.

View Source
var ErrInvalidTitle = errors.New("invalid title")

ErrInvalidTitle indicates an invalid title.

Functions

func Slugify

func Slugify(value string) string

Slugify applies the current slugging policy. It lowercases, strips diacritics and collapses separators into hyphens.

Types

type EntityMetadata

type EntityMetadata struct {
	// contains filtered or unexported fields
}

EntityMetadata is an immutable value object describing an entity's lifetime.

func NewEntityMetadata

func NewEntityMetadata(createdAt, updatedAt time.Time) (EntityMetadata, error)

NewEntityMetadata requires nonzero times with update at or after creation. Stored instants use UTC and omit monotonic clock readings.

func (EntityMetadata) CreatedAt

func (metadata EntityMetadata) CreatedAt() time.Time

CreatedAt returns the original creation instant in UTC.

func (EntityMetadata) IsZero

func (metadata EntityMetadata) IsZero() bool

IsZero reports whether lifecycle metadata is uninitialized.

func (EntityMetadata) Updated

func (metadata EntityMetadata) Updated(at time.Time) (EntityMetadata, error)

Updated returns a copy with a later or equal update time.

func (EntityMetadata) UpdatedAt

func (metadata EntityMetadata) UpdatedAt() time.Time

UpdatedAt returns the most recent update instant in UTC.

type Tag

type Tag struct {
	// contains filtered or unexported fields
}

Tag is a value object representing a normalized tag.

func NewTag

func NewTag(value string) (Tag, error)

NewTag creates a normalized tag.

func (Tag) Equal

func (tag Tag) Equal(other Tag) bool

Equal reports whether two tags have the same normalized value.

func (Tag) IsZero

func (tag Tag) IsZero() bool

IsZero reports whether the tag is uninitialized.

func (Tag) String

func (tag Tag) String() string

String returns the normalized tag value.

type Tags

type Tags struct {
	// contains filtered or unexported fields
}

Tags is a value object: an immutable, ordered collection of unique tags. Its zero value is a valid empty collection.

func NewTags

func NewTags(values ...Tag) (Tags, error)

NewTags creates an ordered collection of unique tags.

func (Tags) Contains

func (tags Tags) Contains(tag Tag) bool

Contains reports whether the collection contains tag.

func (Tags) IsEmpty

func (tags Tags) IsEmpty() bool

IsEmpty reports whether the collection contains no tags.

func (Tags) Items

func (tags Tags) Items() []Tag

Items returns a copy of the normalized tag values.

func (Tags) Len

func (tags Tags) Len() int

Len returns the number of tags.

func (Tags) Strings

func (tags Tags) Strings() []string

Strings returns the normalized tags as strings in their original order.

type Title

type Title struct {
	// contains filtered or unexported fields
}

Title represents a validated, single-line title.

func NewTitle

func NewTitle(value string) (Title, error)

NewTitle creates a validated title that can produce a nonempty slug.

func (Title) IsZero

func (title Title) IsZero() bool

IsZero reports whether the title is uninitialized.

func (Title) Slug

func (title Title) Slug() string

Slug returns the normalized title slug.

func (Title) String

func (title Title) String() string

String returns the title text.

Jump to

Keyboard shortcuts

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