Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrKVStrInvalidToken = errors.New("kv-str invalid token") ErrKVStrReflectError = errors.New("kv-str reflect error") )
Functions ¶
This section is empty.
Types ¶
type FieldName ¶
type FieldName = string
KVStr is a string containing a set of key value pairs
By convention, KV strings are optionally concatenated with space-separated key=value pairs. Each key=value pair is separated by a comma (U+002C ',') or semicolon (U+003B ';')
Each key is a non-empty string that satisfies the syntax of go identity. Value can have four types:
numeric: Any integer, floating point, or complex number
that satisfies the go syntax e.g. `a=1,b=2.,c=.3,d=01 ,e=10e2` => {a:1, b:2, c:.3, d:01, e:10e2}
character: Any character enclosed by single-quotes `'`
e.g. `char='x'` => {char:x}
boolean: Only the value of `false` means that the value
is false, in other cases you can just write key, the `=value` part can be omitted e.g. `switch,window` => {switch:true, window:true}
string: Any character enclosed by back-quotes ```, or
any character concatenation to the next separator that is not one of the above cases, where consecutive whitespace characters are treated as a single whitespace character e.g. `str=this is a string,str2=`quoted string`` => {str:"this is a string", str2="`quoted string`"}
type KVStr ¶
type KVStr string
KVStr is a string containing a set of key value pairs
By convention, KV strings are optionally concatenated with space-separated key=value pairs. Each key=value pair is separated by a comma (U+002C ',') or semicolon (U+003B ';')
Each key is a non-empty string that satisfies the syntax of go identity. Value can have four types:
numeric: Any integer, floating point, or complex number
that satisfies the go syntax e.g. `a=1,b=2.,c=.3,d=01 ,e=10e2` => {a:1, b:2, c:.3, d:01, e:10e2}
character: Any character enclosed by single-quotes `'`
e.g. `char='x'` => {char:x}
boolean: Only the value of `false` means that the value
is false, in other cases you can just write key, the `=value` part can be omitted e.g. `switch,window` => {switch:true, window:true}
string: Any character enclosed by back-quotes ```, or
any character concatenation to the next separator that is not one of the above cases, where consecutive whitespace characters are treated as a single whitespace character e.g. `str=this is a string,str2=`quoted string`` => {str:"this is a string", str2="`quoted string`"}
func (KVStr) ReflectTo ¶
func (kv KVStr) ReflectTo(target any, queryOption *QueryOption) (extra map[string]string, err error)
ReflectTo copies kv by name to a struct
The key used to assign a value should be equal to the name of the field corresponding to the target struct, or the snake form of its name.
e.g. The field `FieldName` can be assigned by the
key `FieldName` or `field_name`.
type KeyName ¶
type KeyName = string
KVStr is a string containing a set of key value pairs
By convention, KV strings are optionally concatenated with space-separated key=value pairs. Each key=value pair is separated by a comma (U+002C ',') or semicolon (U+003B ';')
Each key is a non-empty string that satisfies the syntax of go identity. Value can have four types:
numeric: Any integer, floating point, or complex number
that satisfies the go syntax e.g. `a=1,b=2.,c=.3,d=01 ,e=10e2` => {a:1, b:2, c:.3, d:01, e:10e2}
character: Any character enclosed by single-quotes `'`
e.g. `char='x'` => {char:x}
boolean: Only the value of `false` means that the value
is false, in other cases you can just write key, the `=value` part can be omitted e.g. `switch,window` => {switch:true, window:true}
string: Any character enclosed by back-quotes ```, or
any character concatenation to the next separator that is not one of the above cases, where consecutive whitespace characters are treated as a single whitespace character e.g. `str=this is a string,str2=`quoted string`` => {str:"this is a string", str2="`quoted string`"}