Skip to main content
Version: v1.34.0

How to configure a flag

GO Feature Flag core feature is to centralize all your feature flags in a source file, and to avoid hosting and maintaining a backend server to manage them.

Your file must be a valid YAML, JSON or TOML file with a list of flags (examples: YAML, JSON, TOML).

tip

The easiest way to create your configuration file is to used [GO Feature Flag Editor available at https://editor.gofeatureflag.org.

If you prefer to do it manually please follow instruction bellow.

Editor

Creating the first version of the flag is not always pleasant, that's why we have created GO Feature Flag Editor a simple editor to create your files.

Example

A flag configuration looks like:

# This is your configuration for your first flag
first-flag:
variations: # All possible return value for your feature flag
A: false
B: true
targeting: # If you want to target a subset of your users in particular
- query: key eq "random-key"
percentage:
A: 0
B: 100
defaultRule: # When no targeting match we use the defaultRule
variation: A
metadata:
issue_link: https://github.com/thomaspoignant/go-feature-flag/issues/XXX
description: this is my first feature flag

# A second example of a flag configuration
second-flag:
variations:
A: "valueA"
B: "valueB"
defaultValue: "a default value"
targeting:
- name: legacyRuleV0
query: key eq "not-a-key"
percentage:
A: 10
B: 90
defaultRule:
name: legacyDefaultRule
variation: defaultValue
version: "12"
experimentation:
start: 2021-03-20T00:00:00.1-05:00
end: 2021-03-21T00:00:00.1-05:00

Format details

FieldDescription
flag-key

Name of your flag.


It must be unique.


On the example the flag keys are test-flag and test-flag2.

bucketing-key
(optional)

Selects a key from the evaluation context that will be used in place of the targetingKey for the purpose of evaluating which variant to serve.

If bucketingKey is set and the value is missing from the context, the flag will not be evaluated.

variations

Variations are all the variations available for this flag.

It is represented as a key/value element. The key is the name of the variation and the value could be of any types available ( string, float, int, map, array, bool).

You can have as many variations as needed.

Some examples:


variationString: test


variationBool: true


variationInt: 1000


variationFloat: 1000.23


variationArray:
- item1
- item2


variationObj:
item1: 123
item2: this is a string
item3: false


targeting
(optional)

Targeting contains the list of rules you have to target a subset of your users.


You can have as many target as needed.

This field is an array and contains a list of rules.

See rules format to have more info on how to write a rule.

defaultRule

DefaultRule is the rule that is applied if the user does not match in any targeting.

See rules format to have more info on how to write a rule.

trackEvents
(optional)

false if you don't want to export the data in your data exporter.

Default:true

disable
(optional)

true if the flag is disabled.

Default:false

version
(optional)

The version is the version of your flag.


This string is used to display the information in the notifiers and data collection, you have to update it yourself.

Default:""

metadata
(optional)

This field allows adding a wealth of information about a particular feature flag, such as a configuration URL or the originating Jira issue.

scheduledRollout
(optional)

scheduledRollout allows to patch your flag over time.

You can add several steps that update the flag, this is typically used if you want to gradually add more user in your flag.

See Scheduled rollout to have more info on how to use it.

experimentation
(optional)

Experimentation allows you to configure a start date and an end date for your flag. When the experimentation is not running, the flag will serve the default value.

See Experimentation rollout to have more info on how to use it.

Advanced configurations

You can have advanced configurations for your flag for them to have specific behavior, such as:

Get the latest GO Feature Flag updates