Documentation ¶
Overview ¶
Package cor has some utility function for working with numeric and character literal values.
The literal values of raw, uuid, time and span all have a formatter, string parser and a pointer parser function that returns nil on error.
The primitive go types bool, int64, float64 and string have a pointer helper that returns a pointer to argument value.
Index ¶
- Variables
- func Any(v interface{}) *interface{}
- func Bool(v bool) *bool
- func Cased(s string) string
- func Ctrl(r rune) int
- func Digit(r rune) bool
- func FormatHex(v []byte) string
- func FormatRaw(v []byte) string
- func FormatSpan(v time.Duration) string
- func FormatTime(v time.Time) string
- func FormatUUID(v [16]byte) string
- func Int(v int64) *int64
- func IsCased(s string) bool
- func IsKey(s string) bool
- func IsName(s string) bool
- func IsSym(s string) bool
- func KeyPart(r rune) bool
- func KeyStart(r rune) bool
- func Keyed(s string) string
- func Keyify(s string) string
- func Letter(r rune) bool
- func Milli(v time.Duration) int64
- func MilliSpan(n int64) time.Duration
- func MustParseUUID(s string) [16]byte
- func NamePart(r rune) bool
- func NameStart(r rune) bool
- func NewUUID() (id [16]byte)
- func ParseRaw(s string) ([]byte, error)
- func ParseSpan(s string) (time.Duration, error)
- func ParseTime(s string) (time.Time, error)
- func ParseTimeFormat(s, fmt string) (time.Time, error)
- func ParseUUID(s string) ([16]byte, error)
- func Punct(r rune) bool
- func Quote(s string, q byte) (string, error)
- func Raw(s string) *[]byte
- func Real(v float64) *float64
- func Space(r rune) bool
- func Span(s string) *time.Duration
- func Str(v string) *string
- func SymPart(r rune) bool
- func SymStart(r rune) bool
- func Time(s string) *time.Time
- func UUID(s string) *[16]byte
- func UnixMilli(v time.Time) int64
- func UnixMilliTime(n int64) time.Time
- func Unquote(s string) (string, error)
- func WriteQuote(b writer, s string, q byte) error
- type Path
- type Seg
Constants ¶
This section is empty.
Variables ¶
var ErrSpan = fmt.Errorf("invalid span format")
ErrSpan indicates an invalid input format when parsing a span.
var ErrUUID = fmt.Errorf("invalid uuid format")
ErrUUID indicates an invalid input format when parsing an uuid.
Functions ¶
func Cased ¶
Cased returns n starting with uppercase letter. This function is especially used for go code gen.
func FormatHex ¶
FormatHex returns v as string starting with '\x' and followed by the bytes as lower hex.
func FormatRaw ¶
FormatRaw returns v as string, plain texts are returned as is, otherwise FormatHex is used.
func FormatSpan ¶
FormatSpan returns v in the string format '-123:04:05.678'.
func FormatTime ¶
FormatTime returns v as string in the RFC3339 format with milliseconds.
func FormatUUID ¶
FormatUUID returns v as string in the canonical uuid format.
func MustParseUUID ¶
func ParseSpan ¶
ParseSpan parses s and returns a time duration or an error. It accepts two formats '-123h4m5s678ms' and '-123:04:05.678'.
func ParseTime ¶
ParseTime parses s and return a time or error. It accepts variations of the RFC3339 format:
2006-01-02([T ]15:04(:05:999999999)?)?(Z|[+-]07([:]?00)?)?
The returned time will be parsed in the local timezone if none is specified.
func ParseTimeFormat ¶
ParseTimeFormat parses s with go time fmt in the local timezone and returns a time or error.
func ParseUUID ¶
ParseUUID parses s and return the uuid bytes or an error. It accepts 16 hex encoded bytes with up to four dashes in between.
func Quote ¶
Quote is a json compatible string quoter that works for single and double quotes and back ticks.
func UnixMilliTime ¶
UnixMilliTime constructs and returns a time from the millisecond timestamp since unix epoch.
func Unquote ¶
Unquote is a stripped version of strconv.Unquote. It does not complain about single-quoted string having length greater than 1.
func WriteQuote ¶
Types ¶
type Path ¶
type Path []Seg
Path consists of non-empty segments separated by dots '.' or slashes '/'. Segments starting with a digit or minus sign are idx segments that try to select into an idxr literal, otherwise the segment represents a key used to select into a keyr literal. Segments starting with a slash signify a selection from a idxr literal.