Skip to content

Commit 35e2f21

Browse files
erkasahidvelji
andauthored
chore(unleash): bump minimum Go requirement to 1.24 and modernize (#771)
Signed-off-by: Roman Dmytrenko <[email protected]> Co-authored-by: Sahid Velji <[email protected]>
1 parent c7ddccf commit 35e2f21

File tree

4 files changed

+16
-29
lines changed

4 files changed

+16
-29
lines changed

providers/unleash/go.mod

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
module github.com/open-feature/go-sdk-contrib/providers/unleash
22

3-
go 1.23.0
4-
5-
toolchain go1.24.4
3+
go 1.24.0
64

75
require (
86
github.com/Unleash/unleash-client-go/v4 v4.1.4
@@ -19,7 +17,6 @@ require (
1917
github.com/stretchr/objx v0.5.2 // indirect
2018
github.com/twmb/murmur3 v1.1.8 // indirect
2119
go.uber.org/mock v0.5.2 // indirect
22-
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect
2320
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
2421
gopkg.in/yaml.v3 v3.0.1 // indirect
2522
)

providers/unleash/go.sum

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,8 @@ github.com/Unleash/unleash-client-go/v4 v4.1.4/go.mod h1:k7LRAXyKeZ1DwqGaKn1KZo9
55
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
66
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
77
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
8-
github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
9-
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
108
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
119
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
12-
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
13-
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
1410
github.com/h2non/gock v1.2.0 h1:K6ol8rfrRkUOefooBC8elXoaNGYkpp7y2qcxGG6BzUE=
1511
github.com/h2non/gock v1.2.0/go.mod h1:tNhoxHYW2W42cYkYb1WqzdbYIieALC99kpYr7rH/BQk=
1612
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw=
@@ -24,8 +20,6 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
2420
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
2521
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 h1:W6apQkHrMkS0Muv8G/TipAy/FJl/rCYT0+EuS8+Z0z4=
2622
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms=
27-
github.com/open-feature/go-sdk v1.11.0 h1:4cp9rXl16ZvlMCef7O+I3vQSXae8DzAF0SfV9mvYInw=
28-
github.com/open-feature/go-sdk v1.11.0/go.mod h1:+rkJhLBtYsJ5PZNddAgFILhRAAxwrJ32aU7UEUm4zQI=
2923
github.com/open-feature/go-sdk v1.15.1 h1:TC3FtHtOKlGlIbSf3SEpxXVhgTd/bCbuc39XHIyltkw=
3024
github.com/open-feature/go-sdk v1.15.1/go.mod h1:2WAFYzt8rLYavcubpCoiym3iSCXiHdPB6DxtMkv2wyo=
3125
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
@@ -37,18 +31,14 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
3731
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
3832
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
3933
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
40-
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
41-
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
4234
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
4335
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
4436
github.com/twmb/murmur3 v1.1.8 h1:8Yt9taO/WN3l08xErzjeschgZU2QSrwm1kclYq+0aRg=
4537
github.com/twmb/murmur3 v1.1.8/go.mod h1:Qq/R7NUyOfr65zD+6Q5IHKsJLwP7exErjN6lyyq3OSQ=
4638
go.uber.org/mock v0.5.2 h1:LbtPTcP8A5k9WPXj54PPPbjcI4Y6lhyOZXn+VS7wNko=
4739
go.uber.org/mock v0.5.2/go.mod h1:wLlUxC2vVTPTaE3UD51E0BGOAElKrILxhVSDYQLld5o=
48-
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ=
49-
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc=
50-
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
51-
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
40+
golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M=
41+
golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA=
5242
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
5343
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
5444
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=

providers/unleash/pkg/provider.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func (p *Provider) BooleanEvaluation(ctx context.Context, flag string, defaultVa
9595
}
9696

9797
res := unleash.IsEnabled(flag, unleash.WithFallback(defaultValue), unleash.WithContext(*unleashContext))
98-
flagMetadata := map[string]interface{}{
98+
flagMetadata := map[string]any{
9999
"enabled": res,
100100
}
101101

@@ -176,7 +176,7 @@ func (p *Provider) StringEvaluation(ctx context.Context, flag string, defaultVal
176176
}
177177
}
178178

179-
func (p *Provider) ObjectEvaluation(ctx context.Context, flag string, defaultValue interface{}, evalCtx of.FlattenedContext) of.InterfaceResolutionDetail {
179+
func (p *Provider) ObjectEvaluation(ctx context.Context, flag string, defaultValue any, evalCtx of.FlattenedContext) of.InterfaceResolutionDetail {
180180
if p.status != of.ReadyState {
181181
if p.status == of.NotReadyState {
182182
return of.InterfaceResolutionDetail{
@@ -209,7 +209,7 @@ func (p *Provider) ObjectEvaluation(ctx context.Context, flag string, defaultVal
209209
}
210210

211211
variant := unleash.GetVariant(flag, unleash.WithVariantContext(*unleashContext))
212-
flagMetadata := map[string]interface{}{
212+
flagMetadata := map[string]any{
213213
"enabled": variant.Enabled,
214214
}
215215
if variant.Name == api.DISABLED_VARIANT.Name {
@@ -267,7 +267,7 @@ func toUnleashContext(evalCtx of.FlattenedContext) (*unleashContext.Context, err
267267
return unleashContext, nil
268268
}
269269

270-
func toStr(val interface{}) (string, bool) {
270+
func toStr(val any) (string, bool) {
271271
switch v := val.(type) {
272272
case string:
273273
return v, true

providers/unleash/pkg/provider_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func TestStringEvaluation(t *testing.T) {
120120

121121
evalCtx := of.NewEvaluationContext(
122122
"",
123-
map[string]interface{}{},
123+
map[string]any{},
124124
)
125125
value, _ := ofClient.StringValue(context.Background(), "variant-flag", "", evalCtx)
126126
if value == "" {
@@ -129,15 +129,15 @@ func TestStringEvaluation(t *testing.T) {
129129
}
130130

131131
func TestBooleanEvaluationByUser(t *testing.T) {
132-
resolution := provider.BooleanEvaluation(context.Background(), "users-flag", false, map[string]interface{}{
132+
resolution := provider.BooleanEvaluation(context.Background(), "users-flag", false, map[string]any{
133133
"UserId": "111",
134134
})
135135
enabled, _ := resolution.ProviderResolutionDetail.FlagMetadata.GetBool("enabled")
136136
if enabled == false {
137137
t.Fatalf("Expected feature to be enabled")
138138
}
139139

140-
resolution = provider.BooleanEvaluation(context.Background(), "users-flag", false, map[string]interface{}{
140+
resolution = provider.BooleanEvaluation(context.Background(), "users-flag", false, map[string]any{
141141
"UserId": "2",
142142
})
143143
enabled, _ = resolution.ProviderResolutionDetail.FlagMetadata.GetBool("enabled")
@@ -147,7 +147,7 @@ func TestBooleanEvaluationByUser(t *testing.T) {
147147

148148
evalCtx := of.NewEvaluationContext(
149149
"",
150-
map[string]interface{}{
150+
map[string]any{
151151
"UserId": "111",
152152
"AppName": "test-app",
153153
"CurrentTime": "2006-01-02T15:04:05Z",
@@ -163,7 +163,7 @@ func TestBooleanEvaluationByUser(t *testing.T) {
163163
}
164164

165165
func TestStringEvaluationByCurrentTime(t *testing.T) {
166-
resolution := provider.StringEvaluation(context.Background(), "variant-flag-by-date", "fallback", map[string]interface{}{
166+
resolution := provider.StringEvaluation(context.Background(), "variant-flag-by-date", "fallback", map[string]any{
167167
"UserId": "2",
168168
"CurrentTime": "2025-01-02T15:04:05Z",
169169
})
@@ -179,7 +179,7 @@ func TestStringEvaluationByCurrentTime(t *testing.T) {
179179
t.Fatalf("Expected one of the variant payloads")
180180
}
181181

182-
resolution = provider.StringEvaluation(context.Background(), "variant-flag-by-date", "fallback", map[string]interface{}{
182+
resolution = provider.StringEvaluation(context.Background(), "variant-flag-by-date", "fallback", map[string]any{
183183
"UserId": "2",
184184
"CurrentTime": "2023-01-02T15:04:05Z",
185185
})
@@ -204,9 +204,9 @@ func TestInvalidContextEvaluation(t *testing.T) {
204204
func TestEvaluationMethods(t *testing.T) {
205205
tests := []struct {
206206
flag string
207-
defaultValue interface{}
207+
defaultValue any
208208
evalCtx of.FlattenedContext
209-
expected interface{}
209+
expected any
210210
expectedError string
211211
}{
212212
{flag: "DateExample", defaultValue: false, evalCtx: of.FlattenedContext{}, expected: true, expectedError: ""},
@@ -222,7 +222,7 @@ func TestEvaluationMethods(t *testing.T) {
222222

223223
{"float", 1.23, of.FlattenedContext{"UserID": "123"}, 1.23, "flag not found"},
224224
{"number", int64(43), of.FlattenedContext{"UserID": "123"}, int64(43), "flag not found"},
225-
{"object", map[string]interface{}{"key1": "other-value"}, of.FlattenedContext{"UserID": "123"}, map[string]interface{}{"key1": "other-value"}, "flag not found"},
225+
{"object", map[string]any{"key1": "other-value"}, of.FlattenedContext{"UserID": "123"}, map[string]any{"key1": "other-value"}, "flag not found"},
226226
{"string", "value2", of.FlattenedContext{"UserID": "123"}, "value2", "flag not found"},
227227

228228
{"invalid_user_context", false, of.FlattenedContext{"UserID": "123", "invalid": "value"}, false, ""},

0 commit comments

Comments
 (0)