{"id":19935044,"url":"https://github.com/optimizely/go-sdk","last_synced_at":"2025-05-03T12:30:56.783Z","repository":{"id":35896026,"uuid":"58225893","full_name":"optimizely/go-sdk","owner":"optimizely","description":"Go SDK for Optimizely Feature Experimentation and Optimizely Full Stack (legacy).","archived":false,"fork":false,"pushed_at":"2025-05-01T18:27:44.000Z","size":1914,"stargazers_count":18,"open_issues_count":3,"forks_count":19,"subscribers_count":67,"default_branch":"master","last_synced_at":"2025-05-01T19:30:16.581Z","etag":null,"topics":["optimizely-environment-prod","optimizely-environment-public","optimizely-owner-px"],"latest_commit_sha":null,"homepage":"https://docs.developers.optimizely.com/experimentation/v4.0-full-stack/docs/go-sdk","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/optimizely.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.MD","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-05-06T18:07:26.000Z","updated_at":"2025-05-01T18:27:46.000Z","dependencies_parsed_at":"2023-02-10T11:01:25.079Z","dependency_job_id":"bc12aafb-ec0f-4ca4-a229-f6ef39cc3a0e","html_url":"https://github.com/optimizely/go-sdk","commit_stats":null,"previous_names":[],"tags_count":36,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/optimizely%2Fgo-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/optimizely%2Fgo-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/optimizely%2Fgo-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/optimizely%2Fgo-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/optimizely","download_url":"https://codeload.github.com/optimizely/go-sdk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252190631,"owners_count":21708914,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["optimizely-environment-prod","optimizely-environment-public","optimizely-owner-px"],"created_at":"2024-11-12T23:18:36.806Z","updated_at":"2025-05-03T12:30:55.643Z","avatar_url":"https://github.com/optimizely.png","language":"Go","readme":"# Optimizely Go SDK\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/optimizely/go-sdk)](https://goreportcard.com/report/github.com/optimizely/go-sdk)\n[![Coverage Status](https://coveralls.io/repos/github/optimizely/go-sdk/badge.svg?branch=master)](https://coveralls.io/github/optimizely/go-sdk?branch=master)\n\n\nThis repository houses the Go SDK for use with Optimizely Feature Experimentation and Optimizely Full Stack (legacy).\n\nOptimizely Feature Experimentation is an A/B testing and feature management tool for product development teams that enables you to experiment at every step. Using Optimizely Feature Experimentation allows for every feature on your roadmap to be an opportunity to discover hidden insights. Learn more at [Optimizely.com](https://www.optimizely.com/products/experiment/feature-experimentation/), or see the [developer documentation](https://docs.developers.optimizely.com/experimentation/v4.0.0-full-stack/docs/welcome).\n\nOptimizely Rollouts is [free feature flags](https://www.optimizely.com/free-feature-flagging/) for development teams. You can easily roll out and roll back features in any application without code deploys, mitigating risk for every feature on your roadmap.\n\n## Get Started\n\nRefer to the [Go SDK's developer documentation](https://docs.developers.optimizely.com/experimentation/v4.0.0-full-stack/docs/go-sdk) for detailed instructions on getting started with using the SDK.\n  \n### Requirements  \n\nRequires Golang version:\n\n| SDK Version  | Required Golang Version  |\n|--------------|--------------------------|\n|   v2.0.0     |     1.21.0 or higher     |\n| \u003c v2.0.0     |     1.13 or higher       |\n\n\n### Install the SDK\n\n#### Install from github:\n\n```$sh\ngo get github.com/optimizely/go-sdk/v2\n```\n\n#### Install from source:\n```$sh\ngo get github.com/optimizely/go-sdk/v2\ncd $GOPATH/src/github.com/optimizely/go-sdk/v2\ngo install\n```\n\nNOTE:\nWe practice trunk-based development, and as such our default branch, `master` might not always be the most stable. We do tag releases on Github and you can pin your installation to those particular release versions. One way to do this is to use [*Go Modules*](https://blog.golang.org/using-go-modules) for managing external dependencies:\n\n#### Install using go.mod:\n\n```\nmodule mymodule\n\ngo 1.21.0\n\nrequire (\n\tgithub.com/optimizely/go-sdk/v2 v2.0.0\n)\n```\n\nIf you are already using `go.mod` in your application you can run the following:\n\n```\ngo mod edit -require github.com/optimizely/go-sdk/v2@v2.0.0\n```\n\nNOTE:\n```$sh\ngo get github.com/optimizely/go-sdk/v2/...\n```\nor\n```$sh\ngo get github.com/optimizely/go-sdk/v2/pkg\n```\nwill install it as a package to pkg directory, rather than src directory. It could be useful for future development and vendoring.\n\n\n## Use the Go SDK\n\nSee the example file in examples/main.go.\n\n### Initialization\n\n```\nimport optly \"github.com/optimizely/go-sdk/v2\"\nimport \"github.com/optimizely/go-sdk/v2/client\"\n\n// Simple one-line initialization with the SDK key    \noptlyClient, err := optly.Client(\"SDK_KEY\")    \n\n// You can also instantiate with a hard-coded datafile using our client factory method    \noptimizelyFactory := \u0026client.OptimizelyFactory {        \n  Datafile: []byte(\"datafile_string\"),   \n}    \noptlyClient, err = optimizelyFactory.Client()\n```\n### Make Decisions\n```\nimport ( \n  optly \"github.com/optimizely/go-sdk/v2\" \n) \n\n// instantiate a client \nclient, err := optly.Client(\"SDK_KEY\") \n\n// User attributes are optional and used for targeting and results segmentation \nattributes := map[string]interface{}{ \n  \"state\": \"California\", \n  \"likes_donuts\": true, \n} \n\nuser := client.CreateUserContext(\"optimizely end user\", attributes) \noptions := []decide.OptimizelyDecideOptions{decide.IncludeReasons} \n\ndecision := user.Decide(\"my_flag\", options) \nvar variationKey string \nif variationKey = decision.VariationKey; variationKey == \"\" { \n  fmt.Printf(\"[decide] error: %v\", decision.Reasons) \n  return \n} \n\nif variationKey == \"control\" { \n\t// Execute code for control variation \n} else if variationKey == \"treatment\" { \n\t// Execute code for treatment variation \n}\n```\n\n## SDK Development\n\n### Unit Tests\n\nRun \n``` \nmake test \n```\n\n### Contributing\n\nPlease see [CONTRIBUTING](https://github.com/optimizely/go-sdk/blob/master/CONTRIBUTING.md).\n\n### Credits\n\nThis software is distributed with code from the following open source projects:\n\nmurmur3\nCopyright 2013, Sébastien Paolacci.\nLicense (BSD-3 Clause): https://github.com/twmb/murmur3/blob/master/LICENSE\n\nuuid\nCopyright (c) 2009, 2014 Google Inc. All rights reserved.\nLicense (BSD-3 Clause): https://github.com/google/uuid/blob/master/LICENSE\n\ntestify\nCopyright (c) 2012-2018 Mat Ryer and Tyler Bunnell.\nLicense (MIT): https://github.com/stretchr/testify/blob/master/LICENSE\n\njson-iterator\nCopyright (c) 2016 json-iterator\nLicense (MIT): https://github.com/json-iterator/go/blob/master/LICENSE\n\nsubset\nCopyright (c) 2015, Facebook, Inc. All rights reserved.\nLicense (BSD): https://github.com/facebookarchive/subset/blob/master/license\n\nprofile\nCopyright (c) 2013 Dave Cheney. All rights reserved.\nLicense (BSD): https://github.com/pkg/profile/blob/master/LICENSE\n\nsync\nCopyright (c) 2009 The Go Authors. All rights reserved.\nhttps://github.com/golang/sync/blob/master/LICENSE\n\nopentelemetry-go\nCopyright The OpenTelemetry Authors\nLicense (Apache-2.0): https://github.com/open-telemetry/opentelemetry-go/blob/main/LICENSE\n\n### Other Optimizely SDKs\n\n- Agent - https://github.com/optimizely/agent\n\n- Android - https://github.com/optimizely/android-sdk\n\n- C# - https://github.com/optimizely/csharp-sdk\n\n- Flutter - https://github.com/optimizely/optimizely-flutter-sdk\n\n- Java - https://github.com/optimizely/java-sdk\n\n- JavaScript - https://github.com/optimizely/javascript-sdk\n\n- PHP - https://github.com/optimizely/php-sdk\n\n- Python - https://github.com/optimizely/python-sdk\n\n- React - https://github.com/optimizely/react-sdk\n\n- Ruby - https://github.com/optimizely/ruby-sdk\n\n- Swift - https://github.com/optimizely/swift-sdk","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foptimizely%2Fgo-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foptimizely%2Fgo-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foptimizely%2Fgo-sdk/lists"}