Documentation
¶
Overview ¶
Package containing Token struct and TokenType info. Tokens are the lingua-franca used between all the refmt packages. Users typically do not refer to these types.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsTokenEqual ¶
Checks if the content of two tokens is the same. Tokens are considered the same if their type one of the special consts (map/array open/close) and that type and the optional length field are equal; or, if type indicates a value, then they are the same if those values are equal. In either path, values that are *not* specified as relevant by the Token's Type are disregarded in the comparison.
If the Token.Type is not valid, the result will be false.
This method is primarily useful for testing.
Types ¶
type Token ¶
type Token struct { // The type of token. Indicates which of the value fields has meaning, // or has a special value to indicate beginnings and endings of maps and arrays. Type TokenType Length int // If this is a TMapOpen or TArrOpen, a length may be specified. Use -1 for unknown. Str string // Value union. Only one of these has meaning, depending on the value of 'Type'. Bytes []byte // Value union. Only one of these has meaning, depending on the value of 'Type'. Bool bool // Value union. Only one of these has meaning, depending on the value of 'Type'. Int int64 // Value union. Only one of these has meaning, depending on the value of 'Type'. Uint uint64 // Value union. Only one of these has meaning, depending on the value of 'Type'. Float64 float64 // Value union. Only one of these has meaning, depending on the value of 'Type'. Tagged bool // Extension slot for cbor. Tag int // Extension slot for cbor. Only applicable if tagged=true. }
func (Token) StringSansTag ¶
func (Token) Value ¶
func (t Token) Value() interface{}
Returns the value attached to this token, or nil. This boxes the value into an `interface{}`, which almost certainly incurs a memory allocation via `runtime.convT2E` in the process, so this this method should not be used when performance is a concern.