constructor: allow nil options

This can make it significantly easier to configure libp2p with optional options.
This commit is contained in:
Steven Allen
2019-04-17 16:20:02 -07:00
parent 213863abbc
commit cff9cb577c
4 changed files with 54 additions and 0 deletions

View File

@@ -19,6 +19,9 @@ type Option = config.Option
func ChainOptions(opts ...Option) Option {
return func(cfg *Config) error {
for _, opt := range opts {
if opt == nil {
continue
}
if err := opt(cfg); err != nil {
return err
}