-
Notifications
You must be signed in to change notification settings - Fork 0
/
interface.go
38 lines (29 loc) · 1.36 KB
/
interface.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Package cpy
package cpy
// Gist Доступ к внутренним функциям
func Gist() *impl { return singleton }
// All Copy everything from one to another
func All(toObj interface{}, fromObj interface{}) error {
return singleton.Copy(toObj, fromObj, nil, nil, nil)
}
// Select Copy only the selected fields.
// Use for struct only
func Select(toObj interface{}, fromObj interface{}, fields ...string) error {
return singleton.Copy(toObj, fromObj, fields, nil, nil)
}
// Omit Copy everything from one to another, but skip listed fields.
// Use for struct only
func Omit(toObj interface{}, fromObj interface{}, fields ...string) error {
return singleton.Copy(toObj, fromObj, nil, fields, nil)
}
// Filter Copy everything data which filtration, used for array, slice and map
func Filter(toObj interface{}, fromObj interface{}, filter FilterFn) error {
return singleton.Copy(toObj, fromObj, nil, nil, filter)
}
// Errors
// ErrCopyToObjectUnaddressable Error: Copy to object is unaddressable
func ErrCopyToObjectUnaddressable() error { return singleton.ErrCopyToObjectUnaddressable() }
// ErrCopyFromObjectInvalid Error: Copy from object is invalid
func ErrCopyFromObjectInvalid() error { return singleton.ErrCopyFromObjectInvalid() }
// ErrTypeMapNotEqual Error: Type of map is not equal
func ErrTypeMapNotEqual() error { return singleton.ErrTypeMapNotEqual() }