{"id":19935149,"url":"https://github.com/optimizely/go-sdk-c-wrapper","last_synced_at":"2025-05-03T12:31:06.454Z","repository":{"id":71780322,"uuid":"243389363","full_name":"optimizely/go-sdk-c-wrapper","owner":"optimizely","description":"A C wrapper for the Go SDK enabling Full Stack and Rollouts in C.","archived":false,"fork":false,"pushed_at":"2020-10-01T15:48:28.000Z","size":69,"stargazers_count":1,"open_issues_count":3,"forks_count":4,"subscribers_count":61,"default_branch":"master","last_synced_at":"2023-08-02T05:42:05.357Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-26T23:42:17.000Z","updated_at":"2024-06-19T07:37:32.229Z","dependencies_parsed_at":"2023-03-08T08:15:31.696Z","dependency_job_id":null,"html_url":"https://github.com/optimizely/go-sdk-c-wrapper","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/optimizely%2Fgo-sdk-c-wrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/optimizely%2Fgo-sdk-c-wrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/optimizely%2Fgo-sdk-c-wrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/optimizely%2Fgo-sdk-c-wrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/optimizely","download_url":"https://codeload.github.com/optimizely/go-sdk-c-wrapper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252190735,"owners_count":21708941,"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":[],"created_at":"2024-11-12T23:18:55.974Z","updated_at":"2025-05-03T12:31:06.134Z","avatar_url":"https://github.com/optimizely.png","language":"Go","readme":"# Optimizely Go SDK C Wrapper\n\nThis repository contains a Go SDK C wrapper that enables the Go SDK to be used in C, C++ and other languages compiled to native code. This SDK is currently in Alpha.\n\n## Installation\n\nDownload then build the SDK as shown below.\n\n### Install from source:\n\n```makefile\nmake\n```\n\n## Usage\n\n### Instantiation\n\nInclude the headerfile and initialize the SDK with an SDK Key. The returned handle should be used in subsequent calls.\n\n```c\n#include \u003coptimizely/optimizely-sdk.h\u003e\n...\nint handle = optimizely_sdk_client(\"\u003csdk key\u003e\");\n```\n\nSee API for more details.\n\n### Example: Feature Rollouts\n\nTo see if a feature has been enabled initialize the SDK then call `is_feature_enabled` function.\n\n```c\n...\nint handle = optimizely_sdk_client(sdkkey);\nif (handle == -1) {\n\tfprintf(stderr, \"failed to initialize Optimizely SDK\\n\");\n\treturn 1;\n}\nchar *err = NULL;\nint enabled = optimizely_sdk_is_feature_enabled(handle, feature_name, \u0026attrib, \u0026err);\n...\n```\n\nFor a full example see [examples/is-feature-enabled.c](https://github.com/optimizely/c-sdk/blob/master/examples/is-feature-enabled.c).\n\n## API\n\n**Important:** All strings and string arrays returned by the API must be free'd by the caller.\n\n```c\ntypedef struct optimizely_user_attribute {\n\tchar *name;\n\tint var_type; // 1 = string, 2 = bool, 3 = float, 4 = int\n\tvoid *data;\n} optimzely_user_attribute;\n\ntypedef struct optimizely_user_attributes {\n\tchar *id;\n\tint num_attributes;\n\tstruct optimizely_user_attribute *user_attribute_list;\n} optimizely_user_attributes;\n\n// reintializes the SDK and creates a new handle table\nint optimizely_sdk_init();\n\n// creates a new optimizely SDK and returns a handle or returns -1 if the sdk could not be initialized\nint optimizely_sdk_client(char* sdkkey);\n\n// removes the passed in client handle\nvoid optimizely_sdk_delete_client(int handle);\n\n// checks to see if feature_name is enabled, non zero return means the feature is enabled\nint optimizely_sdk_is_feature_enabled(int handle, char* feature_name,\n                                      optimizely_user_attributes* attributes, char** error);\n\n// returns the string feature variable value\nchar* optimizely_sdk_get_feature_variable_string(int handle, char* feature_name, char* variable_key,\n                                                 optimizely_user_attributes* attributes, char** error);\n\n// returns the boolean feature variable value\nint optimizely_sdk_get_feature_variable_boolean(int handle, char* feature_name, char* variable_key,\n                                                optimizely_user_attributes* attributes, char** error);\n\n// returns the double feature variable value\ndouble optimizely_sdk_get_feature_variable_double(int handle, char* feature_name, char* variable_key,\n                                                  optimizely_user_attributes* attributes,\n                                                  char** error);\n\n// returns the integer feature variable value\nint optimizely_sdk_get_feature_variable_integer(int handle, char* feature_name, char* variable_key,\n                                                optimizely_user_attributes* attributes, char** error);\n\n// returns the variation for the specified experiment key and user attributes\nchar* optimizely_sdk_get_variation(int handle, char* experiment_key,\n                                   optimizely_user_attributes* attributes, char** error);\n\n// returns the feature variable for the specified feature_name and variable_key\n// the variable_type receives a string specifying the variable type\nchar* optimizely_sdk_get_feature_variable(int handle, char* feature_name, char* variable_key,\n                                          optimizely_user_attributes* attributes,\n                                          char** variable_type, char** error);\n\n// activates the specified experiment_key\nchar* optimizely_sdk_activate(int handle, char* experiment_key,\n                              optimizely_user_attributes* attributes, char** error);\n\n// returns a list of the enabled features, the count receives the number of features returned\nchar** optimizely_sdk_get_enabled_features(int handle, optimizely_user_attributes* attributes,\n                                           int* count, char** error);\n\n// returns a list of the enabled feature variables, count contains the feature variable count\n// to get the value of a feature variable call optimizely_sdk_get_feature_variable_\u003ctype\u003e()\nchar** optimizely_sdk_get_all_feature_variables(int handle, char* feature_key,\n                                                optimizely_user_attributes* attributes,\n                                                int* enabled, int* count, char** error);\n\n// tracks the specified event_key\nchar* optimizely_sdk_track(int handle, char* event_key, optimizely_user_attributes* attributes,\n                           float* value, char** error);\n```\n\n## Credits\n\nThis software is built with the following software.\n\n* Golang (c) 2009 The Go Authors License, [BSD 3-Clause](https://golang.org/LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foptimizely%2Fgo-sdk-c-wrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foptimizely%2Fgo-sdk-c-wrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foptimizely%2Fgo-sdk-c-wrapper/lists"}