FeatureToggle library for golang.
Gocchan is inspired by Chanko.
go get -u github.com/naoina/gocchan
Implement the Feature
interface:
type MyFeature struct {}
func (f *MyFeature) ActiveIf(context interface{}, options ...interface{}) bool {
return true
}
Define the function of Feature:
func (f *MyFeature) ExecMyFeature(context interface{}) {
// do something.
}
Add Feature:
gocchan.AddFeature("name of feature", &MyFeature{})
Invoke:
gocchan.Invoke("context", "name of feature", "ExecMyFeature", func() {
// default processes.
})
The function literal passed to 4th argument of the gocchan.Invoke
is called when any errors occurred in method of Feature.
And also when ActiveIf
returns false
is same as above.
See Godoc for more docs.
See hello.go
in _example
and/or run it.
go run hello.go
Gocchan is licensed under the MIT