We've built a simple console application that demonstrates how LaunchDarkly's SDK works.
Below, you'll find the basic build procedure. For more comprehensive instructions, you can visit your Quickstart page or the Go SDK reference guide.
This demo requires Go 1.21 or higher.
-
Set the environment variable
LAUNCHDARKLY_SDK_KEYto your LaunchDarkly SDK key.export LAUNCHDARKLY_SDK_KEY=my-sdk-key -
If there is an existing boolean feature flag in your LaunchDarkly project that you want to evaluate, set
LAUNCHDARKLY_FLAG_KEYto the flag key; otherwise, a boolean flag ofsample-featurewill be assumed.export LAUNCHDARKLY_FLAG_KEY=my-boolean-flag -
On the command line, run
go build. Follow the instruction to rungo mod tidyifgo buildsaid updates to go.mod is needed. -
Run
./hello-go
You should receive the message "The feature flag evaluates to .". The application will run continuously and react to the flag changes in LaunchDarkly.