Documentation
¶
Index ¶
- Variables
- func CleanUp()
- func CustomFieldTagMap(in map[string]string) option
- func DisableCache() option
- func DisableConcurrency() option
- func Dump(dst, src interface{}, opts ...option) error
- func DumpWithContext(ctx context.Context, dst, src interface{}, opts ...option) error
- func Exclude(fields ...string) option
- func FieldAliasMapTagName(tag string) option
- func Only(fields ...string) option
- func SetCache(c Cacher)
- func SetDebug(v bool)
- func SetMaxPoolSize(size int)
- type Cacher
- type Chell
- type ErrNil
- type MapCache
- type ValueSetter
- type Valuer
Constants ¶
This section is empty.
Variables ¶
var (
DefaultCache = newMapCache()
)
Functions ¶
func CleanUp ¶ added in v0.2.0
func CleanUp()
CleanUp releases the global worker pool. You should call this function only once before the main goroutine exits.
func CustomFieldTagMap ¶ added in v0.9.0
CustomFieldTagMap sets custom tag for each field. It will override the default tag settings defined in your struct. The key should be: `<StructName>.<FieldName>`
func DisableCache ¶ added in v0.12.0
func DisableCache() option
DisableCache disables cache strategy
func DisableConcurrency ¶ added in v0.7.0
func DisableConcurrency() option
DisableConcurrency disables concurrency strategy.
func Dump ¶
func Dump(dst, src interface{}, opts ...option) error
Dump dumps src data to dst. You can filter fields with optional config `portal.Only` or `portal.Exclude`.
func DumpWithContext ¶
DumpWithContext dumps src data to dst with an extra context param. You can filter fields with optional config `portal.Only` or `portal.Exclude`.
func Exclude ¶
func Exclude(fields ...string) option
Exclude specifies the fields to exclude. Examples: ``` c := New(Exclude("A")) // exclude field A c := New(Exclude("A[B,C]")) // exclude field B and C of the nested struct A, but other fields of struct A are still selected. ```
func FieldAliasMapTagName ¶ added in v0.4.0
func FieldAliasMapTagName(tag string) option
FieldAliasMapTagName sets the tag name (e.g. `yaml`, `json`) to parse alias of a field name. Example: ```
struct Schema { ID int `json:"id"` }
// portal parses the json tag, and maps `id` -> `ID`. ```
func Only ¶
func Only(fields ...string) option
Only specifies the fields to keep. Examples: ``` c := New(Only("A")) // keep field A only c := New("A[B,C]") // // keep field B and C of the nested struct A ```
func SetMaxPoolSize ¶ added in v0.2.0
func SetMaxPoolSize(size int)
SetMaxPoolSize limits the capacity of all worker pools.
Types ¶
type Chell ¶
type Chell struct {
// contains filtered or unexported fields
}
Chell manages the dumping state.
func New ¶
New creates a new Chell instance with a worker pool waiting to be feed. It's highly recommended to call function `portal.Dump()` or `portal.DumpWithContext()` directly.
func (*Chell) Dump ¶
Dump dumps src data to dst. You can filter fields with optional config `portal.Only` or `portal.Exclude`.
func (*Chell) DumpWithContext ¶
DumpWithContext dumps src data to dst with an extra context param. You can filter fields with optional config `portal.Only` or `portal.Exclude`.
func (*Chell) SetExcludeFields ¶ added in v0.2.0
SetOnlyFields specifies the fields to exclude. Examples: ``` c := New() c.SetExcludeFields("A") // exclude field A c.SetExcludeFields("A[B,C]") // exclude field B and C of the nested struct A, but other fields of struct A are still selected. ```
func (*Chell) SetOnlyFields ¶ added in v0.2.0
SetOnlyFields specifies the fields to keep. Examples: ``` c := New() c.SetOnlyFields("A") // keep field A only c.SetOnlyFields("A[B,C]") // keep field B and C of the nested struct A ```
type MapCache ¶ added in v0.12.0
type MapCache struct {
// contains filtered or unexported fields
}
type ValueSetter ¶
type ValueSetter interface {
SetValue(v interface{}) error
}