Skip to content

imantung/feato

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Report Card Coverage

feato

Simplest possible feature toggle Library in Go

Usage

Convenience function using global instance

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

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

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages