models

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyTitle = "title"
	KeyDate  = "date"
	KeyJSON  = "json"
	KeyID    = "id"
	KeyURL   = "url"
)

Common key names

View Source
const DateFormat = parse.DateFormat

Variables

View Source
var ErrorMissingDate = errors.New("Missing date")
View Source
var ErrorMissingTitle = errors.New("Missing title")
View Source
var ErrorParsing = errors.New("Parsing Error")

Functions

func GetMetaAs added in v0.4.0

func GetMetaAs[T any](ms Metas, key string) (T, bool)

Types

type Entry

type Entry struct {
	// ID is an optional, but recommended field.
	// When marshaling/unmarshaling, if ID is empty, one is generated.
	ID     string
	Title  string
	Date   time.Time
	Fields Metas
}

func (Entry) GenerateURI added in v0.4.0

func (e Entry) GenerateURI() string

func (Entry) MarshalJSON

func (e Entry) MarshalJSON() ([]byte, error)

func (Entry) MarshalText

func (e Entry) MarshalText() ([]byte, error)

func (*Entry) UnmarshalJSON

func (e *Entry) UnmarshalJSON(in []byte) error

func (*Entry) UnmarshalText

func (e *Entry) UnmarshalText(in []byte) error

type Log

type Log struct {
	Name    string
	Entries []Entry
}

func (*Log) UnmarshalText

func (l *Log) UnmarshalText(in []byte) error

type MetaMapOption added in v0.4.0

type MetaMapOption func(*opts)

func MetaStringifyTime added in v0.4.0

func MetaStringifyTime(b bool) MetaMapOption

func MetaTimeFormat added in v0.4.0

func MetaTimeFormat(f string) MetaMapOption

type Metas added in v0.0.3

type Metas map[string]any

A slice of Meta

func (Metas) FlatMap added in v0.4.0

func (ms Metas) FlatMap(options ...MetaMapOption) map[string]any

FlatMap returns a map of ms with structured fields flattened.

func (Metas) Get added in v0.0.8

func (ms Metas) Get(key string) (any, bool)

Returns the value of the Meta with the given key, and a bool indicating if it was found

func (Metas) GetString added in v0.4.0

func (ms Metas) GetString(key string) (string, bool)

func (Metas) Map added in v0.0.3

func (ms Metas) Map(options ...MetaMapOption) map[string]any

Returns a single map containing all the key/values, with flat keys made structured, and removing invalid keys.

func (Metas) MarshalJSON added in v0.0.3

func (ms Metas) MarshalJSON() ([]byte, error)

Implements json.Marshaler

func (Metas) Set added in v0.0.9

func (ms Metas) Set(k string, v any)

Set sets the key to the given value.

func (*Metas) UnmarshalJSON added in v0.0.3

func (ms *Metas) UnmarshalJSON(in []byte) error

Implements json.Unmarshaler

Jump to

Keyboard shortcuts

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