Documentation
¶
Index ¶
- Variables
- func CustomTagLookup(customTag, key string) (value string, ok bool)
- func ParseSettingTagIntoStruct(tag string, sep byte, settings any) error
- func ParseSettingTagToMap(tag string, sep byte) map[string]string
- func ParseSettingTagToStruct[T any](tag string, sep byte) (*T, error)
- type CustomTag
- type SettingTag
- type Tag
- type Tags
- func (t *Tags) Delete(keys ...string)
- func (t *Tags) Get(key string) (*Tag, error)
- func (t *Tags) Iter() iter.Seq[*Tag]
- func (t *Tags) Keys() []string
- func (t *Tags) Len() int
- func (t *Tags) Less(i int, j int) bool
- func (t *Tags) MustGet(key string) *Tag
- func (t *Tags) Set(tag *Tag) error
- func (t *Tags) String() string
- func (t *Tags) Swap(i int, j int)
- func (t *Tags) Tags() []*Tag
Constants ¶
This section is empty.
Variables ¶
var ( ErrTagSyntax = errors.New("bad syntax for struct tag pair") ErrTagKeySyntax = errors.New("bad syntax for struct tag key") ErrTagValueSyntax = errors.New("bad syntax for struct tag value") ErrKeyNotSet = errors.New("tag key not exist") ErrTagNotExist = errors.New("tag not exist") ErrTagIgnore = errors.New("tag ignore") ErrTagKeyMismatch = errors.New("mismatch between key and tag.key") )
Functions ¶
func CustomTagLookup ¶ added in v0.6.0
func ParseSettingTagIntoStruct ¶ added in v0.6.0
func ParseSettingTagToMap ¶ added in v0.6.0
ParseSettingTag 适用于子tag为多配置项
type example struct { db string `specifyTagName:"config:db;default:postgres` }
default sep ;
Types ¶
type CustomTag ¶ added in v0.6.0
type CustomTag string
CustomTag 适用于子tag形式等同于struct tag,区别是struct tag使用"而CustomTag使用'
type SettingTag ¶ added in v0.6.0
type SettingTag string
type Tag ¶
type Tag struct { // Key is the tag key, such as json, xml, etc.. // i.e: `json:"foo,omitempty". Here key is: "json" Key string // Name is a part of the value // i.e: `json:"foo,omitempty". Here name is: "foo" Value string }
Tag defines a single struct's string literal tag
func (*Tag) AddOptions ¶ added in v0.6.0
AddOptions adds the given option for the given key. If the option already exists it doesn't add it again.
func (*Tag) DeleteOptions ¶ added in v0.6.0
DeleteOptions deletes the given options for the given key
type Tags ¶
type Tags struct {
// contains filtered or unexported fields
}
Tags represent a set of tags from a single struct field
func (*Tags) Get ¶
Get returns the tag associated with the given key. If the key is present in the tag the value (which may be empty) is returned. Otherwise the returned value will be the empty string. The ok return value reports whether the tag exists or not (which the return value is nil).
func (*Tags) Keys ¶
Tags returns a Slice of tags. The order is the original tag order unless it was changed.