Skip to content

Commit 69d06e4

Browse files
committed
merge prerelease branch
1 parent b8af015 commit 69d06e4

29 files changed

+251
-275
lines changed

.circleci/config.yml

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,13 @@ workflows:
77
workflow:
88
jobs:
99
- go-test:
10-
name: Go 1.18
11-
docker-image: cimg/go:1.18
12-
with-coverage: true
13-
- go-test:
14-
name: Go 1.17
15-
docker-image: cimg/go:1.17
16-
run-lint: true # golangci-lint currently doesn't run in Go 1.18
10+
name: Go 1.19
11+
docker-image: cimg/go:1.19
12+
run-lint: true
1713
with-coverage: true
1814
- go-test:
19-
name: Go 1.16
20-
docker-image: cimg/go:1.16
15+
name: Go 1.18
16+
docker-image: cimg/go:1.18
2117
- go-test-windows:
2218
name: Windows
2319
- benchmarks
@@ -45,7 +41,7 @@ jobs:
4541

4642
- run:
4743
name: install go-junit-report
48-
command: go install github.com/jstemmer/go-junit-report@latest
44+
command: go install github.com/jstemmer/go-junit-report/v2@v2.0.0
4945

5046
- run: go build ./...
5147

@@ -99,22 +95,22 @@ jobs:
9995
steps:
10096
- checkout
10197
- run:
102-
name: download Go 1.16.14
98+
name: download Go 1.18.5
10399
command: |
104100
$ErrorActionPreference = "Stop"
105-
$installerUrl = "https://go.dev/dl/go1.16.14.windows-amd64.msi"
106-
(New-Object System.Net.WebClient).DownloadFile($installerUrl, "go1.16.14.windows-amd64.msi")
101+
$installerUrl = "https://go.dev/dl/go1.18.5.windows-amd64.msi"
102+
(New-Object System.Net.WebClient).DownloadFile($installerUrl, "go1.18.5.windows-amd64.msi")
107103
- run:
108-
name: install Go 1.16.14
109-
command: Start-Process msiexec.exe -Wait -ArgumentList "/I go1.16.14.windows-amd64.msi /quiet"
104+
name: install Go 1.18.5
105+
command: Start-Process msiexec.exe -Wait -ArgumentList "/I go1.18.5.windows-amd64.msi /quiet"
110106
- run: go version
111107
- run:
112108
name: build and test
113109
command: go test -race ./...
114110

115111
benchmarks:
116112
docker:
117-
- image: cimg/go:1.16
113+
- image: cimg/go:1.19
118114
environment:
119115
CIRCLE_ARTIFACTS: /tmp/circle-artifacts
120116

.golangci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ linters:
3030
- prealloc
3131
- revive
3232
- staticcheck
33-
- structcheck
3433
- stylecheck
3534
- typecheck
3635
- unconvert

.ldrelease/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ repo:
66

77
jobs:
88
- docker:
9-
image: golang:1.16-buster
9+
image: golang:1.18-buster
1010
template:
1111
name: go
1212

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
GOLANGCI_LINT_VERSION=v1.42.1
2+
GOLANGCI_LINT_VERSION=v1.48.0
33

44
LINTER=./bin/golangci-lint
55
LINTER_VERSION_FILE=./bin/.golangci-lint-version-$(GOLANGCI_LINT_VERSION)
@@ -32,11 +32,11 @@ clean:
3232

3333
test: build
3434
go test -run=not-a-real-test ./... # just ensures that the tests compile
35-
go test -race ./...
35+
go test -v -race ./...
3636

3737
test-easyjson: build-easyjson
3838
go test -run=not-a-real-test -tags $(EASYJSON_TAG) ./... # just ensures that the tests compile
39-
go test -tags $(EASYJSON_TAG) -race ./...
39+
go test -v -tags $(EASYJSON_TAG) -race ./...
4040

4141
test-coverage: $(COVERAGE_PROFILE_RAW)
4242
go run github.com/launchdarkly-labs/go-coverage-enforcer@latest $(COVERAGE_ENFORCER_FLAGS) -outprofile $(COVERAGE_PROFILE_FILTERED) $(COVERAGE_PROFILE_RAW)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Applications using the LaunchDarkly Go SDK will generally use the `ldcontext` su
1010

1111
## Supported Go versions
1212

13-
This version of the project has been tested with Go 1.16 and higher.
13+
This version of the project requires a Go version of 1.18 or higher.
1414

1515
## Integration with easyjson
1616

go.mod

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
module github.com/launchdarkly/go-sdk-common/v3
22

3-
go 1.16
3+
go 1.18
44

55
require (
66
github.com/launchdarkly/go-jsonstream/v2 v2.0.0
7-
github.com/launchdarkly/go-test-helpers/v2 v2.3.1
7+
github.com/launchdarkly/go-test-helpers/v3 v3.0.1
88
github.com/mailru/easyjson v0.7.6
99
github.com/stretchr/testify v1.6.1
10+
golang.org/x/exp v0.0.0-20220823124025-807a23277127
11+
)
12+
13+
require (
14+
github.com/davecgh/go-spew v1.1.1 // indirect
15+
github.com/josharian/intern v1.0.0 // indirect
16+
github.com/pmezard/go-difflib v1.0.0 // indirect
17+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
1018
)

go.sum

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,18 @@ github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8Hm
55
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
66
github.com/launchdarkly/go-jsonstream/v2 v2.0.0 h1:5NBbJmQAiUVVfAGR6tPuMITGO2+8mxLD0Azyeqgq5Yw=
77
github.com/launchdarkly/go-jsonstream/v2 v2.0.0/go.mod h1:8WhgeCtJdsc7VXg7tSzQmCYnw+nRAo5ReOLhVYcLiJk=
8-
github.com/launchdarkly/go-test-helpers/v2 v2.3.1 h1:KXUAQVTeHNcWVDVQ94uEkybI+URXI9rEd7E553EsZFw=
9-
github.com/launchdarkly/go-test-helpers/v2 v2.3.1/go.mod h1:L7+th5govYp5oKU9iN7To5PgznBuIjBPn+ejqKR0avw=
8+
github.com/launchdarkly/go-test-helpers/v3 v3.0.1 h1:Z4lUVrh7+hIvL47KVjEBE/owbqqjKUEYTp4aBX/5OZM=
9+
github.com/launchdarkly/go-test-helpers/v3 v3.0.1/go.mod h1:u2ZvJlc/DDJTFrshWW50tWMZHLVYXofuSHUfTU/eIwM=
1010
github.com/mailru/easyjson v0.7.6 h1:8yTIVnZgCoiM1TgqoeTl+LfU5Jg6/xL3QhGQnimLYnA=
1111
github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
1212
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
1313
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
1414
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
15-
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
1615
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
1716
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
17+
golang.org/x/exp v0.0.0-20220823124025-807a23277127 h1:S4NrSKDfihhl3+4jSTgwoIevKxX9p7Iv9x++OEIptDo=
18+
golang.org/x/exp v0.0.0-20220823124025-807a23277127/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE=
1819
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
1920
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
20-
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
21-
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
2221
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
2322
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

ldattr/ref.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
// If a Ref instance was created from an invalid string, or if it is an uninitialized Ref{}, it is
2626
// considered invalid and its Err() method will return a non-nil error.
2727
//
28-
// Syntax
28+
// # Syntax
2929
//
3030
// The string representation of an attribute reference in LaunchDarkly JSON data uses the following
3131
// syntax:
@@ -40,20 +40,20 @@ import (
4040
// respectively. This syntax deliberately resembles JSON Pointer, but no JSON Pointer behaviors other
4141
// than those mentioned here are supported.
4242
//
43-
// Examples
43+
// # Examples
4444
//
4545
// Suppose there is a context whose JSON implementation looks like this:
4646
//
47-
// {
48-
// "kind": "user",
49-
// "key": "value1",
50-
// "address": {
51-
// "street": "value2",
52-
// "city": "value3"
53-
// },
54-
// "groups": [ "value4", "value5" ],
55-
// "good/bad": "value6"
56-
// }
47+
// {
48+
// "kind": "user",
49+
// "key": "value1",
50+
// "address": {
51+
// "street": "value2",
52+
// "city": "value3"
53+
// },
54+
// "groups": [ "value4", "value5" ],
55+
// "good/bad": "value6"
56+
// }
5757
//
5858
// The attribute references "key" and "/key" would both point to "value1".
5959
//
@@ -209,9 +209,9 @@ func (a Ref) Depth() int {
209209
//
210210
// If index is out of range, it returns "" and an empty ldvalue.OptionalInt{}.
211211
//
212-
// NewRef("a").Component(0) // returns ("a", ldvalue.OptionalInt{})
213-
// NewRef("/a/b").Component(1) // returns ("b", ldvalue.OptionalInt{})
214-
// NewRef("/a/3").Component(1) // returns ("3", ldvalue.NewOptionalInt(3))
212+
// NewRef("a").Component(0) // returns ("a", ldvalue.OptionalInt{})
213+
// NewRef("/a/b").Component(1) // returns ("b", ldvalue.OptionalInt{})
214+
// NewRef("/a/3").Component(1) // returns ("3", ldvalue.NewOptionalInt(3))
215215
func (a Ref) Component(index int) (string, ldvalue.OptionalInt) {
216216
if index == 0 && len(a.components) == 0 {
217217
return a.singlePathComponent, ldvalue.OptionalInt{}

ldcontext/builder_multi.go

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"sort"
55

66
"github.com/launchdarkly/go-sdk-common/v3/lderrors"
7+
8+
"golang.org/x/exp/slices"
79
)
810

911
const defaultMultiBuilderCapacity = 3 // arbitrary value based on presumed likely use cases
@@ -17,10 +19,10 @@ const defaultMultiBuilderCapacity = 3 // arbitrary value based on presumed likel
1719
// nested Context for each Kind. MultiBuilder setters return a reference the same builder, so they
1820
// can be chained together:
1921
//
20-
// context := ldcontext.NewMultiBuilder().
21-
// Add(ldcontext.New("my-user-key")).
22-
// Add(ldcontext.NewBuilder("my-org-key").Kind("organization").Name("Org1").Build()).
23-
// Build()
22+
// context := ldcontext.NewMultiBuilder().
23+
// Add(ldcontext.New("my-user-key")).
24+
// Add(ldcontext.NewBuilder("my-org-key").Kind("organization").Name("Org1").Build()).
25+
// Build()
2426
//
2527
// A MultiBuilder should not be accessed by multiple goroutines at once. Once you have called Build(),
2628
// the resulting Context is immutable and is safe to use from multiple goroutines. Instances
@@ -128,23 +130,23 @@ func (m *MultiBuilder) Build() Context {
128130
// detected by calling the context's Err() method. But, if you prefer to use the two-value
129131
// pattern that is common in Go, you can call TryBuild instead:
130132
//
131-
// c, err := ldcontext.NewMultiBuilder().
132-
// Add(context1).Add(context2).
133-
// TryBuild()
134-
// if err != nil {
135-
// // do whatever is appropriate if building the context failed
136-
// }
133+
// c, err := ldcontext.NewMultiBuilder().
134+
// Add(context1).Add(context2).
135+
// TryBuild()
136+
// if err != nil {
137+
// // do whatever is appropriate if building the context failed
138+
// }
137139
//
138140
// The two return values are the same as to 1. the Context that would be returned by Build(),
139141
// and 2. the result of calling Err() on that Context. So, the above example is exactly
140142
// equivalent to:
141143
//
142-
// c := ldcontext.NewMultiBuilder().
143-
// Add(context1).Add(context2).
144-
// Build()
145-
// if c.Err() != nil {
146-
// // do whatever is appropriate if building the context failed
147-
// }
144+
// c := ldcontext.NewMultiBuilder().
145+
// Add(context1).Add(context2).
146+
// Build()
147+
// if c.Err() != nil {
148+
// // do whatever is appropriate if building the context failed
149+
// }
148150
//
149151
// Note that unlike some Go methods where the first return value is normally an
150152
// uninitialized zero value if the error is non-nil, the Context returned by TryBuild in case
@@ -164,17 +166,17 @@ func (m *MultiBuilder) TryBuild() (Context, error) {
164166
// individual kinds from it separately. For instance, in the following example, "multi1" and
165167
// "multi2" end up being exactly the same:
166168
//
167-
// c1 := ldcontext.NewWithKind("kind1", "key1")
168-
// c2 := ldcontext.NewWithKind("kind2", "key2")
169-
// c3 := ldcontext.NewWithKind("kind3", "key3")
169+
// c1 := ldcontext.NewWithKind("kind1", "key1")
170+
// c2 := ldcontext.NewWithKind("kind2", "key2")
171+
// c3 := ldcontext.NewWithKind("kind3", "key3")
170172
//
171-
// multi1 := ldcontext.NewMultiBuilder().Add(c1).Add(c2).Add(c3).Build()
173+
// multi1 := ldcontext.NewMultiBuilder().Add(c1).Add(c2).Add(c3).Build()
172174
//
173-
// c1plus2 := ldcontext.NewMultiBuilder().Add(c1).Add(c2).Build()
174-
// multi2 := ldcontext.NewMultiBuilder().Add(c1plus2).Add(c3).Build()
175+
// c1plus2 := ldcontext.NewMultiBuilder().Add(c1).Add(c2).Build()
176+
// multi2 := ldcontext.NewMultiBuilder().Add(c1plus2).Add(c3).Build()
175177
func (m *MultiBuilder) Add(context Context) *MultiBuilder {
176178
if m.contextsCopyOnWrite {
177-
m.contexts = append([]Context(nil), m.contexts...)
179+
m.contexts = slices.Clone(m.contexts)
178180
m.contextsCopyOnWrite = true
179181
}
180182
if context.Multiple() {

0 commit comments

Comments
 (0)