:pray: If you are using GO Feature Flag please consider to add yourself in the adopters list.
This simple act significantly boosts the project's visibility and credibility, making a substantial contribution to its advancement.
GO Feature Flag is a lightweight and open-source solution that provides a simple and complete feature flag implementation.
The solution has been built to facilitate the usage of feature flags in your code without having to contact any vendor.
Originally, GO Feature Flag was designed as a solution exclusively for the GO
language. With the new standardization of feature flags by the Openfeature project, the solution is now available for multiple languages _(list of supported languages)_ through a simple API server called the relay proxy, which can be hosted.
âšī¸ Info
If you are not familiar with feature flags, I've written an article which explains why feature flags can fasten your iteration cycle.
HTTP
, S3
, Kubernetes
, see full list).JSON
, TOML
and YAML
).S3
, Google cloud storage
, file
, see the full list)_.webhook
and slack
).The code of this demo is available in examples/demo
repository.
Before starting to use GO Feature Flag you should decide if you want to use the GO Module directly or if you want to install the relay proxy.
The GO module is ideal for using GO Feature Flag exclusively in GO projects. If your project involves multiple languages, we recommend using the Open Feature SDKs.
Originally GO Feature Flag was built to be a GOlang only library, but it limits the ecosystem too much.
To be compatible with more languages we have implemented the GO Feature Flag Relay Proxy.
It is a service you can host that provides an API to evaluate your flags, you can call it using HTTP to get your variation.
Since we believe in standardization we are also implementing OpenFeature providers to interact with this API in the language of your choice.
(OpenFeature is still at an early stage, so not all languages are supported and expect some changes in the future)
For now, we have providers for:
Language | Provider | Version |
---|---|---|
Go | Go Provider | |
Java / Kotlin (server) | Java Provider | |
Android / Kotlin (client) | Kotlin Provider | |
Javascript/Typescript (server) | Server provider | |
Javascript/Typescript (client) | Client provider | |
Python | Python provider | |
.Net | .Net Provider | |
PHP | Not currently available help by contributing here | |
Ruby | Not currently available help by contributing here | |
Swift | Not currently available help by contributing here |
The module supports different ways of retrieving the flag file.
The available retrievers are:
_See the full list and more information._
GO Feature Flag core feature is to centralize all your feature flags in a single file and to avoid hosting and maintaining a backend server to manage them.
Your file should be a YAML
, JSON
or TOML
file with a list of flags (examples: YAML
, JSON
, TOML
).
The easiest way to create your configuration file is to use GO Feature Flag Editor available at https://editor.gofeatureflag.org.
If you prefer to do it manually please follow the instruction below.
A flag configuration looks like this:
For detailed information on the fields required to create a flag, please refer to the documentation.
The query format is based on the nikunjy/rules
library.
All the operations can be written in capitalized or lowercase (ex: eq
or EQ
can be used).
Logical Operations supported are AND
OR
.
Compare Expression and their definitions (a|b
means you can use either one of the two a
or b
):
eq|==: equals to
ne|!=: not equals to
lt|<: less than
gt|>: greater than
le|<=: less than equal to
ge|>=: greater than equal to
co: contains
sw: starts with
ew: ends with
in: in a list
pr: present
not: not of a logical expression
key eq "example@example.com"
anonymous ne true
userId eq "12345"
Feature flag targeting and rollouts are all determined by the user you pass to your evaluation calls.
The only required field for a user is his unique key
, it is used by the internals of GO Feature Flag to do a hash to define
if the flag can apply to this user or not.
You can use a primary key, an e-mail address, or a hash, as long as the same user always has the same key.
We recommend using a hash if possible.
All the other attributes are optional.
Since it is useful to make complex queries on your flag, you can add as many information fields you want to your user. It will be used when testing the targeting rules.
You can also distinguish logged-in users from anonymous users in the SDK (check documentation about anonymous users).
The Variation methods determine whether a flag is enabled or not for a specific user.
GO Feature Flag can manage more than just boolean
values; the value of your flag can be any of the following types:
bool
int
float
string
json array
json object
result, _ := ffclient.BoolVariation("your.feature.key", user, false)
// result is now true or false depending on the setting of
// this boolean feature flag
Variation methods take the feature flag key, a user, and a default value.
The default value is returned when an error is encountered (ffclient
not initialized, variation with wrong type, flag does not exist ...).
In the example, if the flag your.feature.key
does not exist, the result will be false
.
Note that the result will always provide a usable value.
If you want to send the information about a specific user to a front-end, you will want a snapshot of all the flags for this user at a specific time.
The method ffclient.AllFlagsState
returns a snapshot of flag values and metadata.
The function is evaluating all available flags for the user and returns a flagstate.AllFlagsState
object containing the
information you need.
The MarshalJSON()
function will return a JSON Object, that can be directly used by your front-end application.
More details in the documentation.
A critical part of every new feature release is orchestrating the actual launch schedule between the Product, Engineering, and Marketing teams.
Delivering powerful user experiences typically requires software teams to manage complex releases and make manual updates at inconvenient times.
But it does not have to, having a complex rollout strategy allows you to have a lifecycle for your flags.
If you want to be informed when a flag has changed, you can configure a notifier.
A notifier will send one notification to the targeted system to inform them that a new flag configuration has been loaded.
âšī¸ GO Feature Flag can handle more than one notifier at a time.
Available notifiers are:
GO Feature Flag allows you to export data about the usage of your flags.
It collects all variation events and can save these events in several locations:
Currently, we are supporting only feature events.
It represents individual flag evaluations and is considered "full fidelity" events.
An example feature event below:
{
"kind": "feature",
"contextKind": "anonymousUser",
"userKey": "ABCD",
"creationDate": 1618228297,
"key": "test-flag",
"variation": "Default",
"value": false,
"default": false,
"source": "SERVER"
}
The format of the data is described in the documentation. Events are collected and sent in bulk to avoid spamming your exporter.
A command line tool is available to help you lint your configuration file: go-feature-flag-lint.
This project welcomes contributions from the community. If you're interested in contributing, see the contributors' guide for some helpful tips.
Thanks so much to our contributors.
If you are using go-feature-flag
, we encourage you to include your company's name in this list. This simple act significantly boosts the project's visibility and credibility, making a substantial contribution to its advancement. To do so, kindly add yourself to adopters.
Here is the list of adopters.