move options under config

This commit is contained in:
Asim Aslam
2019-06-12 12:45:42 +01:00
parent a6e09c9249
commit 97967cbe14
10 changed files with 8 additions and 8 deletions

34
config/options/default.go Normal file
View File

@@ -0,0 +1,34 @@
package options
type defaultOptions struct {
opts *Values
}
type stringKey struct{}
func (d *defaultOptions) Init(opts ...Option) error {
if d.opts == nil {
d.opts = new(Values)
}
for _, o := range opts {
if err := d.opts.Option(o); err != nil {
return err
}
}
return nil
}
func (d *defaultOptions) Values() *Values {
return d.opts
}
func (d *defaultOptions) String() string {
if d.opts == nil {
d.opts = new(Values)
}
n, ok := d.opts.Get(stringKey{})
if ok {
return n.(string)
}
return "Values"
}