common

package
v0.0.0-...-3961003 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2025 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package tabwriter implements a write filter (tabwriter.Writer) that translates tabbed columns in input into properly aligned text.

The package is using the Elastic Tabstops algorithm described at http://nickgravgaard.com/elastictabstops/index.html.

The text/tabwriter package is frozen and is not accepting new features.

Index

Constants

View Source
const (
	// Ignore html tags and treat entities (starting with '&'
	// and ending in ';') as single characters (width = 1).
	FilterHTML uint = 1 << iota

	// Strip Escape characters bracketing escaped text segments
	// instead of passing them through unchanged with the text.
	StripEscape

	// Force right-alignment of cell content.
	// Default is left-alignment.
	AlignRight

	// Handle empty columns as if they were not present in
	// the input in the first place.
	DiscardEmptyColumns

	// Always use tabs for indentation columns (i.e., padding of
	// leading empty cells on the left) independent of padchar.
	TabIndent

	// Print a vertical bar ('|') between columns (after formatting).
	// Discarded columns appear as zero-width columns ("||").
	DDebug
)

Formatting can be controlled with these flags.

View Source
const (
	ENTITY_REGISTRY = iota
	ENTITY_GROUP
	ENTITY_RESOURCE
	ENTITY_META
	ENTITY_VERSION
	ENTITY_MODEL

	ENTITY_GROUP_TYPE
	ENTITY_RESOURCE_TYPE
	ENTITY_VERSION_TYPE
)
View Source
const ANY = "any"

Attribute types

View Source
const ARRAY = "array"
View Source
const BOOLEAN = "boolean"
View Source
const DB_IN = ','

If DB_IN changes then DefaultProps in init.sql needs to change too

View Source
const DB_INDEX = '#'
View Source
const DECIMAL = "decimal"
View Source
const Escape = '\xff'

To escape a text segment, bracket it with Escape characters. For instance, the tab in this string "Ignore this tab: \xff\t\xff" does not terminate a cell and constitutes a single character of width one for formatting purposes.

The value 0xff was chosen because it cannot appear in a valid UTF-8 sequence.

View Source
const HASDOCUMENT = true
View Source
const INTEGER = "integer"
View Source
const IN_CHAR = '.'
View Source
const IN_STR = string(IN_CHAR)
View Source
const MAP = "map"
View Source
const MAXVERSIONS = 0
View Source
const OBJECT = "object"
View Source
const READONLY = false
View Source
const SETDEFAULTSTICKY = true
View Source
const SETVERSIONID = true
View Source
const SINGLEVERSIONROOT = false
View Source
const SPECURL = "https://github.com/xregistry/spec/blob/main/core/spec.md"
View Source
const SPECVERSION = "1.0-rc2"
View Source
const STRICT = true

Model attribute default values

View Source
const STRING = "string"
View Source
const TIMESTAMP = "timestamp"
View Source
const UINTEGER = "uinteger"
View Source
const URI = "uri"
View Source
const URI_REFERENCE = "urireference"
View Source
const URI_TEMPLATE = "uritemplate"
View Source
const URL = "url"
View Source
const UX_IN = '.'
View Source
const XID = "xid"
View Source
const XIDTYPE = "xidtype"

Variables

View Source
var AllowableAPIs = ArrayToLower([]string{
	"/capabilities", "/capabilitiesoffered", "/export",
	"/model", "/modelsource"})
View Source
var AllowableFlags = ArrayToLower([]string{
	"binary", "collections", "doc", "epoch", "filter", "ignore", "inline",
	"setdefaultversionid", "sort", "specversion"})
View Source
var AllowableIgnores = ArrayToLower([]string{
	"capabilities", "defaultversionid", "defaultversionsticky", "epoch",
	"modelsource", "readonly"})
View Source
var AllowableMutable = ArrayToLower([]string{
	"capabilities", "entities", "model"})
View Source
var AllowableSpecVersions = ArrayToLower([]string{"1.0-rc2", SPECVERSION})
View Source
var DefaultCapabilities = &Capabilities{
	APIs:           AllowableAPIs,
	Flags:          SupportedFlags,
	Ignores:        SupportedIgnores,
	Mutable:        AllowableMutable,
	Pagination:     false,
	ShortSelf:      false,
	SpecVersions:   AllowableSpecVersions,
	StickyVersions: PtrBool(true),
}
View Source
var GitCommit = ""
View Source
var JPtrEsc0 = regexp.MustCompile(`~0`)
View Source
var JPtrEsc1 = regexp.MustCompile(`~1`)
View Source
var MASK_SERVER = "MaskServer"
View Source
var NOMASK_INSTANCE = "NoMaskInstance"
View Source
var NOMASK_TS = "NoMaskTS"

Flags

View Source
var PanicLogSet = (os.Getenv("PANICLOG") != "")

TestPanicIf will always log the error but will only panic if the "PANICLOG" env var is set. This allows us to detect non-serious errors during testing but not in production

View Source
var REG_COMMIT = `GitCommit: [0-9a-f]*\n`
View Source
var REG_DBHOST = `DB server: .*`
View Source
var REG_INSTANCE = `"source": "[^"]*"`
View Source
var REG_RFC3339 = `\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[-+]\d{2}:\d{2})`
View Source
var REG_TSSLASH = `\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2}`
View Source
var ShortChars = "" +
	"abcdefghijklmnopqrstuvwxyz" +
	"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
	"0123456789" +

	"-@" // 62-63

Valid tiny URL chars. Number of them needs to be a multiple of 2

View Source
var SupportedFlags = ArrayToLower([]string{
	"binary", "collections", "doc", "epoch", "filter", "ignore", "inline",
	"setdefaultversionid", "sort", "specversion"})
View Source
var SupportedIgnores = ArrayToLower([]string{
	"capabilities", "defaultversionid", "defaultversionsticky", "epoch",
	"modelsource", "readonly"})
View Source
var Type2Error = map[string]*XRError{

	"action_not_supported": &XRError{
		Code:  405,
		Title: `The specified action (<action>) is not supported for: <subject>.`,
	},
	"ancestor_circular_reference": &XRError{
		Code:  400,
		Title: `For "<subject>", the request would create a circular list of ancestors: <list>.`,
	},
	"bad_defaultversionid": &XRError{
		Code:  400,
		Title: `An error was found in the "defaultversionid" value specified (<value>): <error_detail>.`,
	},
	"bad_details": &XRError{
		Code:  400,
		Title: `Use of "$details" in this context is not allowed: <subject>.`,
	},
	"bad_filter": &XRError{
		Code:  400,
		Title: `An error was found in "filter" value (<value>): <error_detail>.`,
	},
	"bad_flag": &XRError{
		Code:  400,
		Title: `The specified flag (<flag>) is not allowed in this context: <subject>.`,
	},
	"bad_ignore": &XRError{
		Code:  400,
		Title: `An error was found in "ignore" value (<value>): <error_detail>.`,
	},
	"bad_inline": &XRError{
		Code:  400,
		Title: `An error was found in "inline" value (<value>): <error_detail>.`,
	},
	"bad_request": &XRError{
		Code:  400,
		Title: `<error_detail>.`,
	},
	"bad_sort": &XRError{
		Code:  400,
		Title: `An error was found in "sort" value (<value>): <error_detail>.`,
	},
	"cannot_doc_xref": &XRError{
		Code:  400,
		Title: `Retrieving the document view of a Version for "<subject>" is not allowed because it uses "xref".`,
	},
	"capability_error": &XRError{
		Code:  400,
		Title: `There was an error in the capabilities provided: <error_detail>.`,
	},
	"capability_missing_specversion": &XRError{
		Code:  400,
		Title: `The "specversions" capability needs to contain "<value>".`,
	},
	"capability_unknown": &XRError{
		Code:  400,
		Title: `Unknown capability specified: <field>.`,
	},
	"capability_value": &XRError{
		Code:  400,
		Title: `Invalid value (<value>) specified for capability "<field>". Allowable values include: <list>.`,
	},
	"capability_wildcard": &XRError{
		Code:  400,
		Title: `When "<field>" includes a value of "*" then no other values are allowed.`,
	},
	"compatibility_violation": &XRError{
		Code:  400,
		Title: `The request would cause one or more Versions of "<subject>" to violate its compatibility rule (<value>).`,
	},
	"data_retrieval_error": &XRError{
		Code:  500,
		Title: `The server was unable to retrieve all of the requested data.`,
	},
	"defaultversionid_request": &XRError{
		Code:  400,
		Title: `Processing "<subject>", the "defaultversionid" attribute is not allowed to be "request" since a Version wasn't processed.`,
	},
	"extra_xref_attribute": &XRError{
		Code:  400,
		Title: `Attribute "<name>" is not allowed to be present since the Resource (<subject>) uses "xref".`,
	},
	"groups_only": &XRError{
		Code:  400,
		Title: `Attribute "<name>" is invalid. Only Group types are allowed to be specified on this request: <subject>.`,
	},
	"inline_noninlineable": &XRError{
		Code:  400,
		Title: `Attempting to inline a non-inlineable attribute (<name>) on: <subject>.`,
	},
	"invalid_attribute": &XRError{
		Code:  400,
		Title: `The attribute "<name>" for "<subject>" is not valid: <error_detail>.`,
	},
	"malformed_id": &XRError{
		Code:  400,
		Title: `The specified ID value (<id>) is malformed: <error_detail>.`,
	},
	"malformed_xid": &XRError{
		Code:  400,
		Title: `The specified XID value (<xid>) is malformed: <error_detail>.`,
	},
	"malformed_xref": &XRError{
		Code:  400,
		Title: `The specified xref value (<xref>) is malformed: <error_detail>.`,
	},
	"mismatched_epoch": &XRError{
		Code:  400,
		Title: `The specified epoch value (<bad_epoch>) for "<subject>" does not match its current value (<epoch>).`,
	},
	"mismatched_id": &XRError{
		Code:  400,
		Title: `The specified "<singular>id" value (<invalid_id>) for "<subject>" needs to be "<expected_id>".`,
	},
	"misplaced_epoch": &XRError{
		Code:  400,
		Title: `The specified "epoch" value for "<subject>" needs to be within a "meta" entity.`,
	},
	"missing_versions": &XRError{
		Code:  400,
		Title: `At least one Version needs to be included in the request to process "<subject>".`,
	},
	"model_compliance_error": &XRError{
		Code:  400,
		Title: `The model provided would cause one or more entities in the Registry to become non-compliant.`,
	},
	"model_error": &XRError{
		Code:  400,
		Title: `There was an error in the model definition provided: <error_detail>.`,
	},
	"model_required_true": &XRError{
		Code:  400,
		Title: `Model attribute "<name>" needs to have a "required" value of "true" since a default value is provided.`,
	},
	"model_scalar_default": &XRError{
		Code:  400,
		Title: `Model attribute "<name>" is not allowed to have a default value since it is not a scalar.`,
	},
	"multiple_roots": &XRError{
		Code:  400,
		Title: `The operation would result in multiple root Versions for "<subject>", which is not allowed for "<plural>".`,
	},
	"not_found": &XRError{
		Code:  404,
		Title: `The targeted entity (<subject>) cannot be found.`,
	},
	"one_resource": &XRError{
		Code:  400,
		Title: `Only one attribute from "<list>" can be present at a time for: <subject>.`,
	},
	"parsing_data": &XRError{
		Code:  400,
		Title: `There was an error parsing the data: <error_detail>.`,
	},
	"readonly": &XRError{
		Code:  400,
		Title: `Updating a read-only entity (<subject>) is not allowed.`,
	},
	"required_attribute_missing": &XRError{
		Code:  400,
		Title: `One or more mandatory attributes for "<subject>" are missing: <list>.`,
	},
	"server_error": &XRError{
		Code:  500,
		Title: `An unexpected error occurred, please try again later.`,
	},
	"setdefaultversionid_not_allowed": &XRError{
		Code:  400,
		Title: `Processing "<subject>", the "setdefaultversionid" flag is not allowed to be specified for entities of type "<singular>".`,
	},
	"setdefaultversionsticky_false": &XRError{
		Code:  400,
		Title: `The model attribute "setdefaultversionsticky" needs to be "false" since "maxversions" is "1".`,
	},
	"sort_noncollection": &XRError{
		Code:  400,
		Title: `Can't sort on a non-collection result set. Query path: <subject>.`,
	},
	"too_large": &XRError{
		Code:  406,
		Title: `The size of the response is too large to return in a single response.`,
	},
	"too_many_versions": &XRError{
		Code:  400,
		Title: `When the "setdefaultversionid" flag is set to "request", only one Version is allowed to be specified in the request message.`,
	},
	"unknown_attribute": &XRError{
		Code:  400,
		Title: `An unknown attribute (<name>) was specified for "<subject>".`,
	},
	"unknown_group_type": &XRError{
		Code:  400,
		Title: `An unknown Group type (<name>) was specified in "<subject>".`,
	},
	"unknown_id": &XRError{
		Code:  400,
		Title: `While processing "<subject>", the "<singular>" with a "<singular>id" value of "<id>" cannot be found.`,
	},
	"unknown_resource_type": &XRError{
		Code:  400,
		Title: `An unknown Resource type (<name>) was specified for Group type "<group>".`,
	},
	"unsupported_specversion": &XRError{
		Code:  400,
		Title: `The specified "specversion" value (<specversion>) is not supported. Supported versions: <list>.`,
	},
	"versionid_not_allowed": &XRError{
		Code:  400,
		Title: `While creating a new Version for "<subject>", a "versionid" was specified but the "setversionid" model aspect for entities of type "<plural>" is "false".`,
	},
	"wrong_defaultversionid": &XRError{
		Code:  400,
		Title: `For "<subject>", the "defaultversionid" needs to be "<id>" since "defaultversionsticky" is "false".`,
	},

	"api_not_found": &XRError{
		Code:  404,
		Title: `The specified API is not supported: <subject>.`,
	},
	"details_required": &XRError{
		Code:  405,
		Title: `$details suffix is needed when using PATCH for the entity: <subject>.`,
	},
	"extra_xregistry_header": &XRError{
		Code:  400,
		Title: `xRegistry HTTP header "<name>" is not allowed on this request: <error_detail>.`,
	},
	"header_error": &XRError{
		Code:  400,
		Title: `There was an error processing HTTP header "<name>": <error_detail>.`,
	},
	"missing_body": &XRError{
		Code:  400,
		Title: `The request is missing an HTTP body - try '{}'.`,
	},

	"exists": &XRError{
		Code:  400,
		Title: `"<subject>" already exists.`,
	},
	"client_error": &XRError{

		Code:  400,
		Title: `<error_detail>.`,
	},
	"parsing_response": &XRError{
		Code:  400,
		Title: `There was an error parsing the response from the server: <error_detail>.`,
	},
	"talking_to_server": &XRError{
		Code:  400,
		Title: `There was an error talking to the server (<subject>): <error_detail>.`,
	},
}

Functions

func AddQuery

func AddQuery(urlPath string, newQuery string) string

func Any2String

func Any2String(val any) string

func AnyToUInt

func AnyToUInt(val any) (int, error)

func ArrayContains

func ArrayContains(strs []string, needle string) bool

func ArrayContainsAnyCase

func ArrayContainsAnyCase(strs []string, needle string) bool

func ArrayToLower

func ArrayToLower(arr []string) []string

func ConvertStrToTime

func ConvertStrToTime(str string) (time.Time, error)

func DownloadURL

func DownloadURL(urlPath string) ([]byte, error)

func EnvBool

func EnvBool(name string, def bool) bool

func EnvInt

func EnvInt(name string, def int) int

func EnvString

func EnvString(name string, def string) string

func Err2String

func Err2String(err error) string

func Fail

func Fail(t *testing.T, str string, args ...any)

func FindModelFile

func FindModelFile(name string) (string, error)

func GetJSONPointer

func GetJSONPointer(data any, path string) (any, error)

func GetStack

func GetStack() []string

func GetStackAsString

func GetStackAsString() string

func HTMLify

func HTMLify(r *http.Request, buf []byte) []byte

func IncludeTraverse

func IncludeTraverse(includeArgs IncludeArgs, data map[string]any) error

data is the current map to check for $include statements

func IsNil

func IsNil(a any) bool

func IsPortInUse

func IsPortInUse(port int) bool

func IsURL

func IsURL(str string) bool

func JSONEscape

func JSONEscape(obj interface{}) string

func JsonErrorToString

func JsonErrorToString(buf []byte, dec *json.Decoder, err error) string

func Keys

func Keys(m interface{}) []string

func LineNum

func LineNum(buf []byte, pos int) int

func MD5

func MD5(str string) string

Convert a string into a unique MD5 string - basically just for cases where we want to create a tiny URL

func MakeShort

func MakeShort(buf []byte) string

Convert a []byte into a string that uses ShortChars as its encoding. Similar to base64 but with a larger char set.

func MaskTimestamps

func MaskTimestamps(input string) string

Mask timestamps, but if (for the same input) the same TS is used, make sure the mask result is the same for just those two

func Match

func Match(pattern string, str string) bool

func MaterializeProp

func MaterializeProp(current any, pp *PropPath, val any, prev *PropPath) (any, error)

func Must

func Must(err any)

func NestedGetProp

func NestedGetProp(obj any, pp *PropPath, prev *PropPath) (any, bool, error)

Value, Found, Error

func NewUUID

func NewUUID() string

func NormalizeStrTime

func NormalizeStrTime(str string) (string, error)

func NotNilBoolDef

func NotNilBoolDef(val *any, def bool) bool

func NotNilBoolPtr

func NotNilBoolPtr(val *bool) bool

func NotNilInt

func NotNilInt(val *any) int

func NotNilIntDef

func NotNilIntDef(val *any, def int) int

func NotNilString

func NotNilString(val *any) string

func ObjectGetProp

func ObjectGetProp(obj any, pp *PropPath) (any, bool, error)

Value, Found, Error

func ObjectSetProp

func ObjectSetProp(obj map[string]any, pp *PropPath, val any) error

Given a PropPath and a value this will add the necessary golang data structures to 'obj' to materialize PropPath and set the appropriate fields to 'val'

func OneLine

func OneLine(buf []byte) []byte

func PanicIf

func PanicIf(b bool, msg string, args ...any)

func Panicf

func Panicf(msg string, args ...any)

func ParseCapabilitiesJSON

func ParseCapabilitiesJSON(buf []byte) (*Capabilities, *XRError)

func ParseJSONToObject

func ParseJSONToObject(data []byte) (interface{}, error)

func PrettyPrintJSON

func PrettyPrintJSON(data []byte, prefix, indent string) ([]byte, error)

PrettyPrintJSON takes a JSON []byte, prefix, and indent, and returns pretty-printed JSON []byte with the original order of attributes and arrays preserved. Note, it will NOT do error/syntax checking - maybe we should at some point

func PtrBool

func PtrBool(b bool) *bool

func PtrBoolDef

func PtrBoolDef(val *any, def bool) *bool

func PtrInt

func PtrInt(i int) *int

func PtrIntDef

func PtrIntDef(val *any, def int) *int

func RemoveComments

func RemoveComments(buf []byte) []byte

func RemoveProps

func RemoveProps(buf []byte) []byte

func RemoveSchema

func RemoveSchema(buf []byte) ([]byte, error)

func ResetMap

func ResetMap[M ~map[K]V, K comparable, V any](m M, key K, oldVal V)

Either delete or change the value of a map based on "oldVal" being nil or not

func ResolvePath

func ResolvePath(baseFile string, next string) string

func Show

func Show(msg string, args ...any)

func ShowStack

func ShowStack()

func SortedKeys

func SortedKeys(m interface{}) []string

func SplitFragement

func SplitFragement(str string) (string, string)

func String2AnySlice

func String2AnySlice(strs []string) []any

func TestPanicIf

func TestPanicIf(b bool, msg string, args ...any)

func ToJSON

func ToJSON(obj interface{}) string

func ToJSONOneLine

func ToJSONOneLine(obj interface{}) string

func Unmarshal

func Unmarshal(buf []byte, v any) error

func ValidateJSONWithPath

func ValidateJSONWithPath(data []byte, v interface{}) error

ValidateJSONWithPath validates JSON data against a Go value, reporting detailed errors with paths for syntax errors, type mismatches, and unknown fields. It uses a custom parser instead of encoding/json. It handles struct fields without json tags by using the field name as the JSON key if exported, supports case-insensitive matching for JSON keys, and reports type mismatches with the Go type as expected. Error messages include "path " before the path, use a single dot for top-level paths (e.g., ".foo"),

func XCheck

func XCheck(t *testing.T, b bool, errStr string, args ...any)

func XCheckErr

func XCheckErr(t *testing.T, errAny any, errStr string)

got, any

func XCheckGreater

func XCheckGreater(t *testing.T, extra string, newAny any, oldAny any)

func XCheckNotEqual

func XCheckNotEqual(t *testing.T, extra string, gotAny any, expAny any)

func XEqual

func XEqual(t *testing.T, extra string, gotAny any, expAny any, flags ...string)

func XGET

func XGET(t *testing.T, url string) (int, string)

http code, body

func XJSONCheck

func XJSONCheck(t *testing.T, gotObj any, expObj any)

func XNoErr

func XNoErr(t *testing.T, errAny any)

func Xid2Abstract

func Xid2Abstract(str string) (string, error)

Types

type Capabilities

type Capabilities struct {
	APIs           []string `json:"apis"`           // must not have omitempty
	Flags          []string `json:"flags"`          // must not have omitempty
	Ignores        []string `json:"ignores"`        // must not have omitempty
	Mutable        []string `json:"mutable"`        // must not have omitempty
	Pagination     bool     `json:"pagination"`     // must not have omitempty
	ShortSelf      bool     `json:"shortself"`      // must not have omitempty
	SpecVersions   []string `json:"specversions"`   // must not have omitempty
	StickyVersions *bool    `json:"stickyversions"` // must not have omitempty
}

func (*Capabilities) APIEnabled

func (c *Capabilities) APIEnabled(str string) bool

func (*Capabilities) FlagEnabled

func (c *Capabilities) FlagEnabled(str string) bool

func (*Capabilities) IgnoresEnabled

func (c *Capabilities) IgnoresEnabled(str string) bool

func (*Capabilities) MutableEnabled

func (c *Capabilities) MutableEnabled(str string) bool

func (*Capabilities) PaginationEnabled

func (c *Capabilities) PaginationEnabled() bool

func (*Capabilities) ShortSelfEnabled

func (c *Capabilities) ShortSelfEnabled(str string) bool

func (*Capabilities) SpecVersionEnabled

func (c *Capabilities) SpecVersionEnabled(str string) bool

func (*Capabilities) StickyVersionsEnabled

func (c *Capabilities) StickyVersionsEnabled() bool

func (*Capabilities) Validate

func (c *Capabilities) Validate() *XRError

type IncludeArgs

type IncludeArgs struct {
	// Cache path/name of "" means stdin
	Cache      map[string]map[string]any // Path#.. -> json
	History    []string                  // Just names, no frag, [0]=latest
	LocalFiles bool                      // ok to access local FS files?
}

type Object

type Object map[string]any

type Offered

type Offered struct {
	APIs           OfferedCapability `json:"apis,omitempty"`
	Flags          OfferedCapability `json:"flags,omitempty"`
	Ignores        OfferedCapability `json:"ignores,omitempty"`
	Mutable        OfferedCapability `json:"mutable,omitempty"`
	Pagination     OfferedCapability `json:"pagination,omitempty"`
	ShortSelf      OfferedCapability `json:"shortself,omitempty"`
	SpecVersions   OfferedCapability `json:"specversions,omitempty"`
	StickyVersions OfferedCapability `json:"stickyversions,omitempty"`
}

func GetOffered

func GetOffered() *Offered

type OfferedCapability

type OfferedCapability struct {
	Type          string       `json:"type,omitempty"`
	Item          *OfferedItem `json:"item,omitempty"`
	Enum          []any        `json:"enum,omitempty"`
	Min           any          `json:"min,omitempty"`
	Max           any          `json:"max,omitempty"`
	Documentation string       `json:"documentation,omitempty"`
}

type OfferedItem

type OfferedItem struct {
	Type string `json:"type,omitempty"`
}

type OrderedMap

type OrderedMap struct {
	Keys   []string
	Values map[string]interface{}
}

OrderedMap holds key-value pairs with order preservation

func (*OrderedMap) MarshalJSON

func (o *OrderedMap) MarshalJSON() ([]byte, error)

MarshalJSON implements custom JSON marshaling to preserve key order

func (*OrderedMap) UnmarshalJSON

func (o *OrderedMap) UnmarshalJSON(data []byte) error

UnmarshalJSON implements custom JSON unmarshaling to preserve key order

type PropPart

type PropPart struct {
	Text  string
	Index int
}

func (*PropPart) IsIndex

func (pp *PropPart) IsIndex() bool

func (*PropPart) ToInt

func (pp *PropPart) ToInt() int

type PropPath

type PropPath struct {
	Parts []PropPart
}

func MustPropPathFromDB

func MustPropPathFromDB(str string) *PropPath

func MustPropPathFromPath

func MustPropPathFromPath(str string) *PropPath

func MustPropPathFromUI

func MustPropPathFromUI(str string) *PropPath

func NewPP

func NewPP() *PropPath

func NewPPP

func NewPPP(prop string) *PropPath

func PropPathFromDB

func PropPathFromDB(str string) (*PropPath, error)

func PropPathFromPath

func PropPathFromPath(str string) (*PropPath, error)

func PropPathFromUI

func PropPathFromUI(str string) (*PropPath, error)

func (*PropPath) Abstract

func (pp *PropPath) Abstract() string

Same as DB() but w/o the trailing ","

func (*PropPath) Append

func (pp *PropPath) Append(addPP *PropPath) *PropPath

func (*PropPath) Bottom

func (pp *PropPath) Bottom() string

func (*PropPath) Clone

func (pp *PropPath) Clone() *PropPath

func (*PropPath) DB

func (pp *PropPath) DB() string

func (*PropPath) Equals

func (pp *PropPath) Equals(other *PropPath) bool

func (*PropPath) First

func (pp *PropPath) First() *PropPath

func (*PropPath) HasPrefix

func (pp *PropPath) HasPrefix(other *PropPath) bool

func (*PropPath) I

func (pp *PropPath) I(i int) *PropPath

func (*PropPath) Index

func (pp *PropPath) Index(i int) *PropPath

func (*PropPath) IsIndexed

func (pp *PropPath) IsIndexed() int

func (*PropPath) Last

func (pp *PropPath) Last() *PropPart

func (*PropPath) Len

func (pp *PropPath) Len() int

func (*PropPath) Next

func (pp *PropPath) Next() *PropPath

func (*PropPath) P

func (pp *PropPath) P(prop string) *PropPath

func (*PropPath) Path

func (pp *PropPath) Path() string

func (*PropPath) Prop

func (pp *PropPath) Prop(prop string) *PropPath

func (*PropPath) RemoveLast

func (pp *PropPath) RemoveLast() *PropPath

func (*PropPath) String

func (pp *PropPath) String() string

func (*PropPath) Top

func (pp *PropPath) Top() string

func (*PropPath) UI

func (pp *PropPath) UI() string

type TabWriter

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

A TabWriter is a filter that inserts padding around tab-delimited columns in its input to align them in the output.

The TabWriter treats incoming bytes as UTF-8-encoded text consisting of cells terminated by horizontal ('\t') or vertical ('\v') tabs, and newline ('\n') or formfeed ('\f') characters; both newline and formfeed act as line breaks.

Tab-terminated cells in contiguous lines constitute a column. The TabWriter inserts padding as needed to make all cells in a column have the same width, effectively aligning the columns. It assumes that all characters have the same width, except for tabs for which a tabwidth must be specified. Column cells must be tab-terminated, not tab-separated: non-tab terminated trailing text at the end of a line forms a cell but that cell is not part of an aligned column. For instance, in this example (where | stands for a horizontal tab):

aaaa|bbb|d
aa  |b  |dd
a   |
aa  |cccc|eee

the b and c are in distinct columns (the b column is not contiguous all the way). The d and e are not in a column at all (there's no terminating tab, nor would the column be contiguous).

The TabWriter assumes that all Unicode code points have the same width; this may not be true in some fonts or if the string contains combining characters.

If DiscardEmptyColumns is set, empty columns that are terminated entirely by vertical (or "soft") tabs are discarded. Columns terminated by horizontal (or "hard") tabs are not affected by this flag.

If a TabWriter is configured to filter HTML, HTML tags and entities are passed through. The widths of tags and entities are assumed to be zero (tags) and one (entities) for formatting purposes.

A segment of text may be escaped by bracketing it with Escape characters. The tabwriter passes escaped text segments through unchanged. In particular, it does not interpret any tabs or line breaks within the segment. If the StripEscape flag is set, the Escape characters are stripped from the output; otherwise they are passed through as well. For the purpose of formatting, the width of the escaped text is always computed excluding the Escape characters.

The formfeed character acts like a newline but it also terminates all columns in the current line (effectively calling TabWriter.Flush). Tab- terminated cells in the next line start new columns. Unless found inside an HTML tag or inside an escaped text segment, formfeed characters appear as newlines in the output.

The TabWriter must buffer input internally, because proper spacing of one line may depend on the cells in future lines. Clients must call Flush when done calling TabWriter.Write.

func NewTabWriter

func NewTabWriter(output io.Writer, lineindent []byte, minwidth, tabwidth, padding int, padchar byte, flags uint) *TabWriter

NewTabWriter allocates and initializes a new TabWriter. The parameters are the same as for the Init function.

func (*TabWriter) Flush

func (b *TabWriter) Flush() error

Flush should be called after the last call to TabWriter.Write to ensure that any data buffered in the TabWriter is written to output. Any incomplete escape sequence at the end is considered complete for formatting purposes.

func (*TabWriter) Init

func (b *TabWriter) Init(output io.Writer, lineindent []byte, minwidth, tabwidth, padding int, padchar byte, flags uint) *TabWriter

A TabWriter must be initialized with a call to Init. The first parameter (output) specifies the filter output. The remaining parameters control the formatting:

lineindent  chars to add to the front of each line  (custom/new)
minwidth    minimal cell width including any padding
tabwidth    width of tab characters (equivalent number of spaces)
padding     padding added to a cell before computing its width
padchar     ASCII char used for padding
        if padchar == '\t', the TabWriter will assume that the
        width of a '\t' in the formatted output is tabwidth,
        and cells are left-aligned independent of align_left
        (for correct-looking results, tabwidth must correspond
        to the tab width in the viewer displaying the result)
flags       formatting control

func (*TabWriter) Write

func (b *TabWriter) Write(buf []byte) (n int, err error)

Write writes buf to the writer b. The only errors returned are ones encountered while writing to the underlying output stream.

type XRError

type XRError struct {
	Type     string
	Code     int // HTTP response code
	Title    string
	Args     map[string]string
	Subject  string
	Detail   string
	Instance string
	Source   string
	Headers  map[string]string // HTTP headers to include in response
}

func CleanArray

func CleanArray(arr []string, full []string, text string) ([]string, *XRError)

func IncomingObj2Map

func IncomingObj2Map(incomingObj Object) (map[string]Object, *XRError)

func NewXRError

func NewXRError(daType string, subject string, args ...string) *XRError

func ParseXRError

func ParseXRError(buf []byte) (*XRError, error)

func ProcessIncludes

func ProcessIncludes(file string, buf []byte, localFiles bool) ([]byte, *XRError)

func (*XRError) AddSource

func (xErr *XRError) AddSource(src string) *XRError

func (*XRError) AddSourceParent

func (xErr *XRError) AddSourceParent() *XRError

Add the caller's parent func to the Source. Used by popular util func to add parent to the Source's stack trace

func (*XRError) GetTitle

func (xErr *XRError) GetTitle() string

func (*XRError) IsType

func (xErr *XRError) IsType(daType string) bool

func (*XRError) SetArgs

func (xErr *XRError) SetArgs(args ...string) *XRError

func (*XRError) SetCode

func (xErr *XRError) SetCode(c int) *XRError

func (*XRError) SetDetail

func (xErr *XRError) SetDetail(msg string) *XRError

func (*XRError) SetDetailf

func (xErr *XRError) SetDetailf(msg string, args ...any) *XRError

func (*XRError) SetHeader

func (xErr *XRError) SetHeader(name, value string) *XRError

func (*XRError) SetSubject

func (xErr *XRError) SetSubject(s string) *XRError

func (*XRError) SetTitle

func (xErr *XRError) SetTitle(t string) *XRError

func (*XRError) String

func (xErr *XRError) String() string

func (*XRError) ToJSON

func (xErr *XRError) ToJSON(baseURL string) string

type Xid

type Xid struct {
	Type       int // one of ENTITY_XXX constants below
	IsEntity   bool
	HasDetails bool

	Group      string
	GroupID    string
	Resource   string
	ResourceID string
	Version    string // "versions" or "meta"
	VersionID  string
}

func ParseXid

func ParseXid(xidStr string) (*Xid, error)

func ParseXref

func ParseXref(xidStr string) (*Xid, error)

func (*Xid) AddPath

func (xid *Xid) AddPath(str string) (*Xid, error)

func (*Xid) String

func (xid *Xid) String() string

func (*Xid) ToAbstract

func (xid *Xid) ToAbstract() string

type XidType

type XidType struct {
	Type int // one of ENTITY_XXX constants below

	Group    string
	Resource string
	Version  string // "versions" or "meta"
}

func ParseXidType

func ParseXidType(xidTypeStr string) (*XidType, error)

Jump to

Keyboard shortcuts

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