Welcome to the quickstart guide for Optimizely's Go SDK. The instructions below will help you implement Optimizely Rollouts and launch your first feature flag.
This guide will help you:
- Install the SDK
- Instantiate the Optimizely Client
- Create a feature flag
- Roll out the feature
The Go SDK is open source and available on GitHub.
You can install using the following command:
go get github.com/optimizely/go-sdk
go get github.com/optimizely/go-sdk cd $GOPATH/src/github.com/optimizely/go-sdk go install
The datafile stores the configuration for all your features and rollouts. Whenever you make a change in Optimizely, the datafile is automatically updated so you can pull configuration changes down into your application.
The sample below shows how you can get a local copy of the datafile from our server and instantiate a client with it. Later, you'll want to adjust this code to handle datafile updates.
If you see <Your_SDK_Key> in the sample above, here's where to find your SDK Key:
- Navigate to Settings > Environments.
- Copy the SDK Key / Primary URL.
Click to enlarge
Choose a feature in your app to turn on and off with a feature flag. For your first flag, consider starting with a link or visual element that's simple to change, show, or hide based on a boolean.
To set up your first feature flag, navigate to Features > Create New Feature.
Here's how to set it up:
Click to enlarge.
The userID enables you to create consistent experiences for a user across multiple visits, but you don't need it for this quickstart. Make the userID any non-null string for now.
Navigate back to Features and select your feature flag.
You'll return to this modal whenever you want to update this feature flag. For example, roll out your feature incrementally by moving the slider up by 10% per day or show it to a certain group of users. Move it to 100% for a big reveal, or 0% if issues arise in production. No code deployment necessary.
Click to enlarge.
A basic way to confirm that your feature flag is working:
Show the feature to yourself
- Navigate to your feature.
- Toggle it ON and move the slider to 100% traffic. Click Save.
- Confirm that you see the feature.
Hide the feature from yourself
- Navigate back to the feature.
- Toggle it OFF. Click Save.
- Confirm that you no longer see the feature.
When you're ready, go ahead and launch your feature in production. Come back and adjust its configuration any time, without deploying code.
Updated 2 months ago