From 19e0b3a7210fe961c3a20f181e6896c21ec651d1 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Fri, 28 Aug 2020 12:27:52 +0300 Subject: [PATCH] NewXXX always returns without error Signed-off-by: Vasiliy Tolstov --- registry.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/registry.go b/registry.go index 7f5d737..445db02 100644 --- a/registry.go +++ b/registry.go @@ -30,7 +30,7 @@ type rtr struct { } // NewRouter creates new router and returns it -func NewRouter(opts ...router.Option) (router.Router, error) { +func NewRouter(opts ...router.Option) router.Router { // get default options options := router.DefaultOptions() @@ -45,17 +45,13 @@ func NewRouter(opts ...router.Option) (router.Router, error) { initChan: make(chan bool), } - if options.Registry == nil { - return nil, fmt.Errorf("registry not set") - } - // create the new table, passing the fetchRoute method in as a fallback if // the table doesn't contain the result for a query. r.table = newTable(r.lookup) // start the router r.start() - return r, nil + return r } // Init initializes router with given options @@ -66,6 +62,10 @@ func (r *rtr) Init(opts ...router.Option) error { } r.Unlock() + if r.options.Registry == nil { + return fmt.Errorf("registry not set") + } + // push a message to the init chan so the watchers // can reset in the case the registry was changed go func() {