Documentation
¶
Index ¶
- Constants
- Variables
- func GetMetaAs[T any](ms Metas, key string) (T, bool)
- type Entry
- type Log
- type MetaMapOption
- type Metas
- func (ms Metas) FlatMap(options ...MetaMapOption) map[string]any
- func (ms Metas) Get(key string) (any, bool)
- func (ms Metas) GetString(key string) (string, bool)
- func (ms Metas) Map(options ...MetaMapOption) map[string]any
- func (ms Metas) MarshalJSON() ([]byte, error)
- func (ms Metas) Set(k string, v any)
- func (ms *Metas) UnmarshalJSON(in []byte) error
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 ¶
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 (Entry) MarshalJSON ¶
func (Entry) MarshalText ¶
func (*Entry) UnmarshalJSON ¶
func (*Entry) UnmarshalText ¶
type Log ¶
func (*Log) UnmarshalText ¶
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
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
Returns the value of the Meta with the given key, and a bool indicating if it was found
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
Implements json.Marshaler
func (*Metas) UnmarshalJSON ¶ added in v0.0.3
Implements json.Unmarshaler
Click to show internal directories.
Click to hide internal directories.