https://github.com/imantung/feato
https://github.com/imantung/feato
feature-flag feature-toggle
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/imantung/feato
- Owner: imantung
- License: mit
- Created: 2019-05-06T08:14:41.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-08-29T09:32:45.000Z (over 5 years ago)
- Last Synced: 2025-02-11T13:31:37.103Z (about 1 year ago)
- Topics: feature-flag, feature-toggle
- Language: Go
- Homepage:
- Size: 30.3 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
[](https://goreportcard.com/report/github.com/imantung/feato)
[](https://gocover.io/github.com/imantung/feato)
# feato
[Simplest possible **fea**ture **to**ggle](https://www.thoughtworks.com/radar/techniques?blipid=202005002) Library in Go
## Usage
Convenience function using global instance
```go
feato.RegisterGlobal([]*feato.Feature{
{Name: "group01", Childs: []*feato.Feature{
{Name: "name03", Flag: feato.Enabled},
{Name: "name04", Flag: feato.Disabled},
}},
})
if feato.IsEnabled("group01.name03") {
fmt.Println("group01.name03 is enabled")
}
// Output: group01.name03 is enabled
```
Parseable to JSON or other format
```go
flagMap := make(feato.FlagMap, 0)
feato.Register(flagMap, []*feato.Feature{
{Name: "name01", Flag: feato.Enabled},
{Name: "name02", Flag: feato.Disabled},
{Name: "group01", Childs: []*feato.Feature{
{Name: "name03", Flag: feato.Enabled},
{Name: "name04", Flag: feato.Disabled},
{Name: "sub01", Flag: feato.Enabled, Childs: []*feato.Feature{
{Name: "name05", Flag: feato.Enabled},
{Name: "name06", Flag: feato.Disabled},
}},
}},
})
b, _ := json.MarshalIndent(flagMap, "", " ")
fmt.Println(string(b))
// Output: {
// "group01.name03": true,
// "group01.name04": false,
// "group01.sub01": true,
// "group01.sub01.name05": true,
// "group01.sub01.name06": false,
// "name01": true,
// "name02": false
// }
```
## References
-
-