fix(selector): set global do not work (#2489)
* fix(selector): set global do not work * fix(selector): test * fix(selector): return early * fix(selector): use struct * fix(selector): use structpull/2500/head
parent
e9ef3eea2d
commit
383f28faeb
@ -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 |
||||
} |
||||
|
Loading…
Reference in new issue