Go Other
Clone or download
Permalink
Failed to load latest commit information.
.circleci Add basic test coverage for streaming and polling (#88) Jun 14, 2018
redis Fix lint issues and enable more linters and go versions (#83) Jun 11, 2018
scripts Add script to udpate version on release. (#15) Nov 16, 2017
shared_test Fix lint issues and enable more linters and go versions (#83) Jun 11, 2018
vendor/github.com Add eventsource 1.0.0 dependency Jun 14, 2018
.golangci.yml Lint fixes Jun 13, 2018
.gometalinter.json Fix lint issues and enable more linters and go versions (#83) Jun 11, 2018
CHANGELOG.md Update Changelog for release of version 4.2.1 Jun 27, 2018
CODEOWNERS Create CODEOWNERS Oct 25, 2017
CONTRIBUTING.md fix more links Jan 23, 2018
Gopkg.lock Add eventsource 1.0.0 dependency Jun 14, 2018
Gopkg.toml Add eventsource 1.0.0 dependency Jun 14, 2018
LICENSE.txt Add CONTRIBUTING.md, update copyright Aug 9, 2016
Makefile DRY up and simplify code (#85) Jun 13, 2018
README.md update readme to include proxy info (#80) May 15, 2018
event_processor.go prepare 4.2.0 release (#125) Jun 26, 2018
event_processor_test.go prepare 4.2.0 release (#125) Jun 26, 2018
event_summarizer.go prepare v4 release (#119) May 10, 2018
event_summarizer_test.go prepare v4 release (#119) May 10, 2018
events.go Fix lint issues and enable more linters and go versions (#83) Jun 11, 2018
events_output.go Fix lint issues and enable more linters and go versions (#83) Jun 11, 2018
feature_store.go DRY up and simplify code (#85) Jun 13, 2018
feature_store_test.go prepare v4 release (#119) May 10, 2018
flag.go DRY up and simplify code (#85) Jun 13, 2018
flag_test.go prepare v4 release (#119) May 10, 2018
ldclient.go Preparing for release of version 4.2.1 Jun 27, 2018
ldclient_test.go Return control immediately to application on 401 errors other initial… Jun 13, 2018
legacy_feature.go DRY up and simplify code (#85) Jun 13, 2018
lru_cache.go prepare v4 release (#119) May 10, 2018
lru_cache_test.go prepare v4 release (#119) May 10, 2018
operators.go Fix lint issues and enable more linters and go versions (#83) Jun 11, 2018
operators_test.go Auto-format source tree Mar 8, 2018
polling.go Fix polling processor to poll more than once (#126) Jun 27, 2018
polling_test.go Fix polling processor to poll more than once (#126) Jun 27, 2018
requestor.go Add basic test coverage for streaming and polling (#88) Jun 14, 2018
segment.go DRY up and simplify code (#85) Jun 13, 2018
segment_test.go Introduce segments. Feb 3, 2018
streaming.go prepare 4.2.0 release (#125) Jun 26, 2018
streaming_test.go prepare 4.2.0 release (#125) Jun 26, 2018
user.go Fix lint issues and enable more linters and go versions (#83) Jun 11, 2018
user_filter.go prepare v4 release (#119) May 10, 2018
user_filter_test.go prepare v4 release (#119) May 10, 2018
user_test.go Add test for NewUser Mar 5, 2018
util.go prepare 4.2.0 release (#125) Jun 26, 2018
util_test.go Auto-format source tree Mar 8, 2018
versioned_data.go Fix lint issues and enable more linters and go versions (#83) Jun 11, 2018

README.md

LaunchDarkly SDK for Go

Circle CI

Quick setup

  1. Install the SDK with the go tool:
go get gopkg.in/launchdarkly/go-client.v4
  1. Import the LaunchDarkly client:
import ld "gopkg.in/launchdarkly/go-client.v4"
  1. Create a new LDClient with your SDK key:
ldClient, err := ld.MakeClient("YOUR_SDK_KEY", 5*time.Second)
if err != nil {
    log.Fatalf("Error creating launch darkly client: %s", err)
}
defer ldClient.Close()

If you are reusing a global instance you probably want to not defer ldClient.Close() but instead close it when the application exits.

HTTPS proxy

Go's standard HTTP library provides built-in support for the use of an HTTPS proxy. If the HTTPS_PROXY environment variable is present then the SDK will proxy all network requests through the URL provided.

How to set the HTTPS_PROXY environment variable on Mac/Linux systems:

export HTTPS_PROXY=https://web-proxy.domain.com:8080

How to set the HTTPS_PROXY environment variable on Windows systems:

set HTTPS_PROXY=https://web-proxy.domain.com:8080

If your proxy requires authentication then you can prefix the URN with your login information:

export HTTPS_PROXY=http://user:pass@web-proxy.domain.com:8080

or

set HTTPS_PROXY=http://user:pass@web-proxy.domain.com:8080

Your first feature flag

  1. Create a new feature flag on your dashboard
  2. In your application code, use the feature's key to check whether the flag is on for each user:
key := "user@test.com"
showFeature, _ := ldClient.BoolVariation("your.flag.key", ld.User{Key: &key}, false)
if showFeature {
    // application code to show the feature
} else {
    // the code to run if the feature is off
}

Building without Redis

The SDK includes an adapter for caching feature flag data in Redis, using Redigo. If you don't intend to use Redis and would like to avoid installing Redigo, add the following build tag to your go build command:

-tags launchdarkly_no_redis

Learn more

Check out our documentation for in-depth instructions on configuring and using LaunchDarkly. You can also head straight to the complete reference guide for this SDK.

Testing

We run integration tests for all our SDKs using a centralized test harness. This approach gives us the ability to test for consistency across SDKs, as well as test networking behavior in a long-running application. These tests cover each method in the SDK, and verify that event sending, flag evaluation, stream reconnection, and other aspects of the SDK all behave correctly.

Contributing

We encourage pull-requests and other contributions from the community. We've also published an SDK contributor's guide that provides a detailed explanation of how our SDKs work.

About LaunchDarkly

  • LaunchDarkly is a continuous delivery platform that provides feature flags as a service and allows developers to iterate quickly and safely. We allow you to easily flag your features and manage them from the LaunchDarkly dashboard. With LaunchDarkly, you can:
    • Roll out a new feature to a subset of your users (like a group of users who opt-in to a beta tester group), gathering feedback and bug reports from real-world use cases.
    • Gradually roll out a feature to an increasing percentage of users, and track the effect that the feature has on key metrics (for instance, how likely is a user to complete a purchase if they have feature A versus feature B?).
    • Turn off a feature that you realize is causing performance problems in production, without needing to re-deploy, or even restart the application with a changed configuration file.
    • Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan). Disable parts of your application to facilitate maintenance, without taking everything offline.
  • LaunchDarkly provides feature flag SDKs for
  • Explore LaunchDarkly