Skip to content

Commit

Permalink
Minor refinement; go-mod-upgrade (does testify rely on spew?)
Browse files Browse the repository at this point in the history
  • Loading branch information
deemount committed Mar 18, 2024
1 parent 45eb2a8 commit 2706b99
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 20 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/deemount/gobpmnTypes v0.0.0-20240315111519-43046016ad9f // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ github.com/deemount/gobpmnTypes v0.0.0-20240315111519-43046016ad9f h1:0gux6KtY8X
github.com/deemount/gobpmnTypes v0.0.0-20240315111519-43046016ad9f/go.mod h1:Dw7Jo8/vr0DzNHNMnbwQu0JSMWm2klNdo00rcxHCzJs=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
Expand Down
22 changes: 5 additions & 17 deletions internals/utils/merge.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package utils

import "reflect"

// MergeStringSliceToMap ...
// MergeStringSliceToMap merges a string slice to a map
// with a string key and a slice of interfaces. If the
// key does not exist, it creates a new key-value pair.
// If the key exists, it appends the slice to the existing
// slice.
func MergeStringSliceToMap(m map[string][]interface{}, k string, v []interface{}) {
if m[k] == nil {
m[k] = make([]interface{}, len(v))
Expand All @@ -13,17 +15,3 @@ func MergeStringSliceToMap(m map[string][]interface{}, k string, v []interface{}
m[k] = append(m[k], v...)
}
}

func MergeStructs(dst, src interface{}) {
dstVal := reflect.ValueOf(dst).Elem()
srcVal := reflect.ValueOf(src).Elem()

for i := 0; i < srcVal.NumField(); i++ {
srcField := srcVal.Field(i)
dstField := dstVal.FieldByName(srcVal.Type().Field(i).Name)

if dstField.IsValid() && dstField.CanSet() {
dstField.Set(srcField)
}
}
}

0 comments on commit 2706b99

Please sign in to comment.