Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type StructTag ¶
type StructTag struct { // Key name which is the first item of a struct tag Key string // Flags OmitEmpty bool Default string }
StructTag stores information about the struct tags which includes the name of the Key and optional flags like `omitempty` and `default`.
The following string can be parsed as StructTag:
s := "properties:test_key,omitempty,default=test_key_default_value" st, err := ParseStructTag(s)
And information can be accessed:
st.Key // returns "test_key" st.OmitEmpty // return true st.Default // returns "test_key_default_value"
func ParseStructTag ¶
ParseStructTag returns a pointer to a StructTag object holding the information resulted from parsing the s string as a struct tag.
func (StructTag) Skip ¶
Skip method returns true if the Key field of the StructTag is either an empty string or `-` meaning that the struct field should not be considered during marshal/unmarshal.
Calling Skip method for st1 or st2 StructTag object will result false:
s1 := "properties:,omitempty,default=test_key_default_value" st1, err := ParseStructTag(s1) st1.Skip()
Or
s2 := "properties:-,omitempty,default=test_key_default_value" st2, err := ParseStructTag(s2) st2.Skip()
Click to show internal directories.
Click to hide internal directories.