You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
519 B
30 lines
519 B
package featureflags
|
|
|
|
import (
|
|
"sync"
|
|
)
|
|
|
|
var features = make(map[string]bool)
|
|
var lock = &sync.RWMutex{}
|
|
|
|
// Get feature will return true if the feature is enabled, otherwise false
|
|
func Get(feature string) bool {
|
|
lock.RLock()
|
|
defer lock.RUnlock()
|
|
res := features[feature]
|
|
return res
|
|
}
|
|
|
|
// Enable a feature
|
|
func Enable(feature string) {
|
|
lock.Lock()
|
|
defer lock.Unlock()
|
|
features[feature] = true
|
|
}
|
|
|
|
// Disable a feature
|
|
func Disable(feature string) {
|
|
lock.Lock()
|
|
defer lock.Unlock()
|
|
features[feature] = false
|
|
}
|
|
|