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 struct
pull/2500/head
Cluas 2 years ago committed by GitHub
parent e9ef3eea2d
commit 383f28faeb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      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
}

Loading…
Cancel
Save