diff --git a/init/init.go b/init/init.go deleted file mode 100644 index a9db1ebc..00000000 --- a/init/init.go +++ /dev/null @@ -1,21 +0,0 @@ -// Package init is an interface for initialising options -package init - -// Options is used for initialisation -type Options interface { - // Initialise options - Init(...Option) error - // Options returns the current options - Options() Options - // Value returns an option value - Value(k interface{}) (interface{}, bool) - // The name for who these options exist - String() string -} - -// NewOptions returns a new initialiser -func NewOptions(opts ...Option) Options { - o := new(defaultOptions) - o.Init(opts...) - return o -} diff --git a/init/default.go b/options/default.go similarity index 97% rename from init/default.go rename to options/default.go index 97d26e35..7b236db2 100644 --- a/init/default.go +++ b/options/default.go @@ -1,4 +1,4 @@ -package init +package options type defaultOptions struct { opts *Values diff --git a/init/options.go b/options/options.go similarity index 69% rename from init/options.go rename to options/options.go index ad99a056..830adea8 100644 --- a/init/options.go +++ b/options/options.go @@ -1,9 +1,21 @@ -package init +package options import ( "sync" ) +// Options is used for initialisation +type Options interface { + // Initialise options + Init(...Option) error + // Options returns the current options + Options() Options + // Value returns an option value + Value(k interface{}) (interface{}, bool) + // The name for who these options exist + String() string +} + // Values holds the set of option values and protects them type Values struct { sync.RWMutex @@ -53,3 +65,10 @@ func WithOption(o Option) Option { func String(s string) Option { return WithValue(stringKey{}, s) } + +// NewOptions returns a new initialiser +func NewOptions(opts ...Option) Options { + o := new(defaultOptions) + o.Init(opts...) + return o +}