will branch off into a maps test
This commit is contained in:
@@ -21,13 +21,17 @@ func main() {
|
|||||||
Ignore: []string{"one", "two", "four", "seven"},
|
Ignore: []string{"one", "two", "four", "seven"},
|
||||||
}
|
}
|
||||||
|
|
||||||
mergo.Merge(&dest, src, mergo.WithTransformers())
|
mergo.Merge(&dest, src, mergo.WithTransformers(StringSliceTransformer{}))
|
||||||
fmt.Println(dest)
|
fmt.Println(dest)
|
||||||
// Will print
|
// Will print
|
||||||
// {two 2}
|
// {two 2}
|
||||||
}
|
}
|
||||||
|
|
||||||
func MergeStrings(typ reflect.Type) func(dst, src reflect.Value) error {
|
type StringSliceTransformer struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
// MergeStrings merges two strings
|
||||||
|
func (s StringSliceTransformer) Transformer(typ reflect.Type) func(dst, src reflect.Value) error {
|
||||||
if typ == reflect.TypeOf([]string{}) {
|
if typ == reflect.TypeOf([]string{}) {
|
||||||
return func(dst, src reflect.Value) error {
|
return func(dst, src reflect.Value) error {
|
||||||
|
|
||||||
|
@@ -1,10 +1,16 @@
|
|||||||
package common
|
package common
|
||||||
|
|
||||||
//FileTypes is for ignoring files to add or ignoring compress, or for locked files, all use the same type of struct (files, folders and exts)
|
//FileTypes is for ignoring files to add or ignoring compress, or for locked files, all use the same type of struct (files, folders and exts)
|
||||||
|
// type FileTypes struct {
|
||||||
|
// Files []string `toml:"files"`
|
||||||
|
// Exts []string `toml:"exts"`
|
||||||
|
// Folders []string `toml:"folders"`
|
||||||
|
// }
|
||||||
|
|
||||||
type FileTypes struct {
|
type FileTypes struct {
|
||||||
Files []string `toml:"files"`
|
Files map[string]string `toml:"files"`
|
||||||
Exts []string `toml:"exts"`
|
Folders map[string]string `toml:"folders"`
|
||||||
Folders []string `toml:"folders"`
|
Exts map[string]string `toml:"exts"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// RepoRefreshRequest returns locks, ignores, and commits/branches. Server marshals into this, client unmarshals
|
// RepoRefreshRequest returns locks, ignores, and commits/branches. Server marshals into this, client unmarshals
|
||||||
|
Reference in New Issue
Block a user