Skip to content

unlaunch/go-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unlaunch Go SDK

main development Go Report Card
Build Status Build Status Go Report Card

Overview

The Unlaunch Go SDK provides a Go API to access Unlaunch feature flags and other features. Using the SDK, you can easily build Java applications that can evaluate feature flags, dynamic configurations, and more.

Important Links

Getting Started

Here is a simple example.

Run go get github.com/unlaunch/go-sdk add it to your go.mod file.

package main

import (
	"fmt"
	"time"
	"github.com/unlaunch/go-sdk/unlaunchio/client"
)

func main() {
	config := client.DefaultConfig()
	factory, err := client.NewUnlaunchClientFactory("YOUR_SERVER_KEY", config)

	if err != nil {
		fmt.Printf("Error initializing Unlaunch client %s\n", err)
		return
	}

	unlaunchClient := factory.Client()
	if err = unlaunchClient.AwaitUntilReady(3 * time.Second); err != nil {
		fmt.Printf("Unlaunch Client wasn't ready %s\n", err)
	}

	variation := unlaunchClient.Variation("FLAG_KEY", "USER_ID_123", nil)

	if variation == "on" {
		// show feature
	} else {
		// don't show feature
	}
}

Offline Mode

You can start the SDK in offline mode for testing purposes. In offline mode, flags aren't downloaded from the server and no data is sent. All calls to Variation or its variants will return control. Read more in the official guide.

To set offline mode :

config := client.DefaultConfig()
config.OfflineMode = true

Build Instructions

To run all tests

go test ./...

How to Publish

Create a new tag on GitHub in the following format vx.y.z e.g. v0.0.1

Submitting issues

If you run into any problems, bugs, or have any questions or feedback, please report them using the issues feature. We'll respond to all issues usually within 24 to 48 hours.

Contributing

Please see CONTRIBUTING to find how you can contribute.

License

Licensed under the Apache License, Version 2.0. See: Apache License.

About Unlaunch

Unlaunch is a Feature Release Platform for engineering teams. Our mission is allow engineering teams of all sizes to release features safely and quickly to delight their customers. To learn more about Unlaunch, please visit unlaunch.io. You can sign up to get started for free at https://app.unlaunch.io/signup.