diff --git a/selector/global.go b/selector/global.go index 2f951212b..4d6b6202c 100644 --- a/selector/global.go +++ b/selector/global.go @@ -1,13 +1,21 @@ package selector -var globalSelector Builder +var globalSelector = &wrapSelector{} + +var _ Builder = (*wrapSelector)(nil) + +// wrapSelector wrapped Selector, help override global Selector implementation. +type wrapSelector struct{ Builder } // GlobalSelector returns global selector builder. func GlobalSelector() Builder { - return globalSelector + if globalSelector.Builder != nil { + return globalSelector + } + return nil } // SetGlobalSelector set global selector builder. func SetGlobalSelector(builder Builder) { - globalSelector = builder + globalSelector.Builder = builder }