camfish/mock/config.go

27 lines
563 B
Go

package mock
import "iter"
import "git.tebibyte.media/sashakoshka/camfish"
var _ camfish.Config = new(Config)
// Config implements camfish.Config.
type Config map[string] []string
func (config Config) Get(key string) string {
list, ok := config[key]
if !ok { return "" }
if len(list) == 0 { return "" }
return list[0]
}
func (config Config) GetAll(key string) iter.Seq2[int, string] {
return func(yield func(int, string) bool) {
list, ok := config[key]
if !ok { return }
for index, value := range list {
yield(index, value)
}
}
}