ConfigCat Go SDK https://configcat.com
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
media
resources
.gitignore
.travis.yml
LICENSE
README.md
async.go
async_result.go
auto_polling_policy.go
auto_polling_policy_test.go
config_cache.go
config_fetcher.go
config_fetcher_test.go
config_parser.go
config_parser_test.go
configcat_client.go
configcat_client_async_test.go
configcat_client_test.go
constants.go
fake_config_provider.go
fetch_response.go
lazy_loading_policy.go
lazy_loading_policy_test.go
manual_polling_policy.go
manual_polling_policy_test.go
refresh_policy.go
rollout_evaluator.go
rollout_integration_test.go
user.go
version.go

README.md

ConfigCat SDK for Go

ConfigCat SDK for Go provides easy integration between ConfigCat service and applications using Go.

ConfigCat is a feature flag, feature toggle, and configuration management service. That lets you launch new features and change your software configuration remotely without actually (re)deploying code. ConfigCat even helps you do controlled roll-outs like canary releases and blue-green deployments. https://configcat.com

Build Status Go Report Card codecov GoDoc License

Getting started

1. Install the package with go

go get gopkg.in/configcat/go-sdk.v1

2. Log in to ConfigCat Management Console and go to your Project to get your API Key:

API-KEY

3. Import the ConfigCat client package to your application

import gopkg.in/configcat/go-sdk.v1

4. Create a ConfigCat client instance:

client := configcat.NewClient("#YOUR-API-KEY#")

5. Get your setting value:

isMyAwesomeFeatureEnabled, ok := client.GetValue("isMyAwesomeFeatureEnabled", false).(bool)
if ok && isMyAwesomeFeatureEnabled {
    DoTheNewThing()
} else {
    DoTheOldThing()
}

Or use the async APIs:

client.GetValueAsync("isMyAwesomeFeatureEnabled", false, func(result interface{}) {
    isMyAwesomeFeatureEnabled, ok := result.(bool)
    if ok && isMyAwesomeFeatureEnabled {
        DoTheNewThing()
    } else {
        DoTheOldThing()
    }
})

6. Close ConfigCat client on application exit:

client.Close()

Getting user specific setting values with Targeting

Using this feature, you will be able to get different setting values for different users in your application by passing a User Object to the getValue() function.

Read more about Targeting here.

user := configcat.NewUser("#USER-IDENTIFIER#")

isMyAwesomeFeatureEnabled, ok := client.GetValueForUser("isMyAwesomeFeatureEnabled", user, false).(bool)
if ok && isMyAwesomeFeatureEnabled {
    DoTheNewThing()
} else {
    DoTheOldThing()
}

Polling Modes

The ConfigCat SDK supports 3 different polling mechanisms to acquire the setting values from ConfigCat. After latest setting values are downloaded, they are stored in the internal cache then all requests are served from there. Read more about Polling Modes and how to use them at ConfigCat Docs.

Support

If you need help how to use this SDK feel free to to contact the ConfigCat Staff on https://configcat.com. We're happy to help.

Contributing

Contributions are welcome.

About ConfigCat