Finished the mapping between dynamo attribute values and tamarin values
This commit is contained in:
parent
3bf5b6ec93
commit
348251c1cf
5 changed files with 294 additions and 23 deletions
23
internal/common/maputils/map.go
Normal file
23
internal/common/maputils/map.go
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
package maputils
|
||||
|
||||
func Values[K comparable, T any](ts map[K]T) []T {
|
||||
values := make([]T, 0, len(ts))
|
||||
for _, v := range ts {
|
||||
values = append(values, v)
|
||||
}
|
||||
return values
|
||||
}
|
||||
|
||||
func MapValuesWithError[K comparable, T, U any](ts map[K]T, fn func(t T) (U, error)) (map[K]U, error) {
|
||||
us := make(map[K]U)
|
||||
|
||||
for k, t := range ts {
|
||||
var err error
|
||||
us[k], err = fn(t)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return us, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue