Go SDK installation

2 minute read

Control feature rollout for certain user segments of your application with feature flags. To start using feature management in the platform, follow the instructions below to install the SDK and deploy a feature flag.

These same instructions are available in the platform UI. Select Installation from the left pane to use.

To install the SDK:

  1. Select the next to Feature management on the left pane, and then select Installation.

  2. Select an Environment from the options, or create an environment by completing the following:


    2. Enter an Environment name.

    3. (Optional) Enter a Description.

    4. (Optional) Select Approvers if you want to have a manual approval required before deployment.

    5. (Optional) Enter any Properties you want to associate with the environment. For more information, refer to properties configuration and properties in an environment.

    6. Select SUBMIT.

  3. Select Go from the language options, and the package manager Get is selected by default.

  4. Add the ROX package to your application by running the shell command appropriate for the package manager:

    go get -u github.com/rollout/rox-go/v5/...
  5. Add the following code to your Go application:

    Your SDK key is a unique environment identifier. During SDK installation, the SDK key is displayed within the Rox.setup call.
    package main // Import CloudBees platform SDK import "fmt" import "github.com/rollout/rox-go/v5/server" // Create Rox flags in the Flags container class type Flags struct { EnableTutorial server.RoxFlag } var flags = &Flags{ // Define the feature flags EnableTutorial: server.NewRoxFlag(false), } var rox *server.Rox func main() { options := server.NewRoxOptions(server.RoxOptionsBuilder{}) rox := server.NewRox() // Register the flags container with the CloudBees platform rox.RegisterWithEmptyNamespace(flags) // Setup the feature management environment key <-rox.Setup("<your-SDK-key>", options)(1) // Boolean flag example fmt.Println("EnableTutorial's value is " + flags.EnableTutorial.IsEnabled(nil)) }
    1 The platform provides the unique SDK key for your environment at the <your-SDK-key> location within the Rox.setup call.
  6. Run your application and then select TEST INTEGRATION to confirm a successful connection.

After running the application, a default flag is automatically added to your feature flag list.

You have installed an SDK and created flags in your application.

Refer to the SDK reference for more information.