corso/src/internal/common/configs.go
Keepers a13f1cc3a6
remove common maps, add golang maps (#1885)
## Description

replaces the common/maps.go code with the
golang experimental maps package. The
maps package provides standard api
such as Keys, Values, Copy, and Clone.

https://pkg.go.dev/golang.org/x/exp/maps

## Does this PR need a docs update or release note?

- [x]  No 

## Type of change

- [x] 🐹 Trivial/Minor

## Test Plan

- [x]  Unit test
2022-12-21 18:08:26 +00:00

25 lines
490 B
Go

package common
import "golang.org/x/exp/maps"
type StringConfigurer interface {
StringConfig() (map[string]string, error)
}
// UnionStringConfigs unions all provided configurers into a single
// map[string]string matching type.
func UnionStringConfigs(cfgs ...StringConfigurer) (map[string]string, error) {
union := map[string]string{}
for _, cfg := range cfgs {
c, err := cfg.StringConfig()
if err != nil {
return nil, err
}
maps.Copy(union, c)
}
return union, nil
}