@@ -29,14 +29,14 @@ module mymodule
29
29
go 1.12
30
30
31
31
require (
32
- github.com/optimizely/go-sdk v1.0.0-beta7
32
+ github.com/optimizely/go-sdk v1.0.0-rc1
33
33
)
34
34
```
35
35
36
36
If you are already using ` go.mod ` in your application you can run the following:
37
37
38
38
```
39
- go mod edit -require github.com/optimizely/[email protected] beta7
39
+ go mod edit -require github.com/optimizely/[email protected] rc1
40
40
```
41
41
42
42
NOTE:
@@ -55,38 +55,36 @@ will install it as a package to pkg directory, rather than src directory. It cou
55
55
To start using the SDK, create an instance using our factory method:
56
56
57
57
```
58
- import "github.com/optimizely/go-sdk/pkg/client"
58
+ import optly "github.com/optimizely/go-sdk"
59
+ import "github.com/optimizely/go-sdk/client"
59
60
60
- optimizelyFactory := &client.OptimizelyFactory{
61
- SDKKey: "[SDK_KEY_HERE]",
62
- }
61
+ // Simple one-line initialization with the SDK key
62
+ client, err := optly.Client("SDK_KEY")
63
63
64
- client, err := optimizelyFactory.Client()
65
-
66
- // You can also instantiate with a hard-coded datafile
64
+ // You can also instantiate with a hard-coded datafile using our client factory method
67
65
optimizelyFactory := &client.OptimizelyFactory{
68
66
Datafile: []byte("datafile_string"),
69
67
}
70
68
71
- client, err : = optimizelyFactory.Client()
69
+ client, err = optimizelyFactory.Client()
72
70
73
71
```
74
72
75
73
### Feature Rollouts
76
74
```
77
75
import (
78
- "github.com/optimizely/go-sdk/pkg/client"
79
- "github.com/optimizely/go-sdk/pkg/entities"
76
+ optly "github.com/optimizely/go-sdk"
80
77
)
81
78
82
- user := entities.UserContext{
83
- ID: "optimizely end user",
84
- Attributes: map[string]interface{}{
85
- "state": "California",
86
- "likes_donuts": true,
87
- },
88
- }
79
+ // instantiate a client
80
+ client, err := optly.Client("SDK_KEY")
89
81
82
+ // User attributes are optional and used for targeting and results segmentation
83
+ atributes := map[string]interface{}{
84
+ "state": "California",
85
+ "likes_donuts": true,
86
+ },
87
+ user := optly.UserContext("optimizely end user", attributes)
90
88
enabled, _ := client.IsFeatureEnabled("binary_feature", user)
91
89
```
92
90
0 commit comments