Skip to content

Commit e3371f7

Browse files
committed
merge prerelease branch
1 parent ee73eda commit e3371f7

File tree

85 files changed

+4975
-3230
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+4975
-3230
lines changed

.circleci/config.yml

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,18 @@ orbs:
66
workflows:
77
workflow:
88
jobs:
9+
- go-test:
10+
name: Go 1.18
11+
docker-image: cimg/go:1.18
12+
with-coverage: true
913
- go-test:
1014
name: Go 1.17
1115
docker-image: cimg/go:1.17
12-
run-lint: true
16+
run-lint: true # golangci-lint currently doesn't run in Go 1.18
1317
with-coverage: true
1418
- go-test:
1519
name: Go 1.16
1620
docker-image: cimg/go:1.16
17-
- go-test:
18-
name: Go 1.15
19-
docker-image: cimg/go:1.15
20-
- go-test:
21-
name: Go 1.14
22-
docker-image: cimg/go:1.14
2321
- go-test-windows:
2422
name: Windows
2523
- benchmarks
@@ -47,7 +45,7 @@ jobs:
4745

4846
- run:
4947
name: install go-junit-report
50-
command: go get -u github.com/jstemmer/go-junit-report
48+
command: go install github.com/jstemmer/go-junit-report@latest
5149

5250
- run: go build ./...
5351

@@ -101,22 +99,22 @@ jobs:
10199
steps:
102100
- checkout
103101
- run:
104-
name: download Go 1.14.13
102+
name: download Go 1.16.14
105103
command: |
106104
$ErrorActionPreference = "Stop"
107-
$installerUrl = "https://golang.org/dl/go1.14.13.windows-amd64.msi"
108-
(New-Object System.Net.WebClient).DownloadFile($installerUrl, "go1.14.13.windows-amd64.msi")
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")
109107
- run:
110-
name: install Go 1.14.13
111-
command: Start-Process msiexec.exe -Wait -ArgumentList "/I go1.14.13.windows-amd64.msi /quiet"
108+
name: install Go 1.16.14
109+
command: Start-Process msiexec.exe -Wait -ArgumentList "/I go1.16.14.windows-amd64.msi /quiet"
112110
- run: go version
113111
- run:
114112
name: build and test
115113
command: go test -race ./...
116114

117115
benchmarks:
118116
docker:
119-
- image: cimg/go:1.15
117+
- image: cimg/go:1.16
120118
environment:
121119
CIRCLE_ARTIFACTS: /tmp/circle-artifacts
122120

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ linters-settings:
4444
gofmt:
4545
simplify: false
4646
goimports:
47-
local-prefixes: gopkg.in/launchdarkly,github.com/launchdarkly
47+
local-prefixes: github.com/launchdarkly
4848

4949
issues:
5050
exclude-use-default: false

.ldrelease/config.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ repo:
66

77
jobs:
88
- docker:
9-
image: golang:1.14-buster
9+
image: golang:1.16-buster
1010
template:
1111
name: go
12-
env:
13-
LD_RELEASE_GO_IMPORT_PATH: gopkg.in/launchdarkly/go-sdk-common.v2
1412

1513
branches:
14+
- name: v3
15+
description: 3.x - for Go SDK 6+
1616
- name: v2
1717
description: 2.x - for Go SDK 5+
1818
- name: v1
1919
description: 1.x - for Go SDK 4.x
2020

2121
publications:
22-
- url: https://godoc.org/gopkg.in/launchdarkly/go-sdk-common.v2
22+
- url: https://godoc.org/github.com/launchdarkly/go-sdk-common/v3
2323
description: documentation

CONTRIBUTING.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ We encourage pull requests and other contributions from the community. Before su
1414

1515
### Prerequisites
1616

17-
This project should be built against Go 1.13 or newer.
18-
19-
Note that the base import path is `gopkg.in/launchdarkly/go-sdk-common.v2`, not `github.com/launchdarkly/go-sdk-common`; all references in this code to other packages within the repository must use that same base import path. This ensures that the package can be referenced not only as a Go module, but also by projects that use older tools like `dep` and `govendor`, because the 5.x release of the Go SDK supports either module or non-module usage. Future releases of this package, and of the Go SDK, may drop support for non-module usage.
17+
This project should be built against the lowest supported Go version as described in [README.md](./README.md).
2018

2119
### Building
2220

Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ clean:
3131
go clean
3232

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

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

3941
test-coverage: $(COVERAGE_PROFILE_RAW)
4042
go run github.com/launchdarkly-labs/go-coverage-enforcer@latest $(COVERAGE_ENFORCER_FLAGS) -outprofile $(COVERAGE_PROFILE_FILTERED) $(COVERAGE_PROFILE_RAW)
@@ -70,7 +72,7 @@ benchmark-allocs:
7072

7173
$(LINTER_VERSION_FILE):
7274
rm -f $(LINTER)
73-
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s $(GOLANGCI_LINT_VERSION)
75+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s $(GOLANGCI_LINT_VERSION)
7476
touch $(LINTER_VERSION_FILE)
7577

7678
lint: $(LINTER_VERSION_FILE)

README.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
# LaunchDarkly Go SDK Core Packages
22

3-
[![Circle CI](https://circleci.com/gh/launchdarkly/go-sdk-common.svg?style=shield)](https://circleci.com/gh/launchdarkly/go-sdk-common) [![Documentation](https://img.shields.io/static/v1?label=go.dev&message=reference&color=00add8)](https://pkg.go.dev/gopkg.in/launchdarkly/go-sdk-common.v2)
3+
[![Circle CI](https://circleci.com/gh/launchdarkly/go-sdk-common.svg?style=shield)](https://circleci.com/gh/launchdarkly/go-sdk-common) [![Documentation](https://img.shields.io/static/v1?label=go.dev&message=reference&color=00add8)](https://pkg.go.dev/github.com/launchdarkly/go-sdk-common/v3)
44

55
## Overview
66

77
This repository contains packages and types that are shared between the [LaunchDarkly Go SDK](https://github.com/launchdarkly/go-server-sdk) and other LaunchDarkly Go components.
88

9-
Applications using the LaunchDarkly Go SDK will generally use the `lduser` subpackage, which contains the `User` type, and may also use the `ldvalue` package, which contains the `Value` type that represents arbitrary JSON values. Other packages are less frequently used.
10-
11-
Note that the base import path is `gopkg.in/launchdarkly/go-sdk-common.v2`, not `github.com/launchdarkly/go-sdk-common`. This ensures that the package can be referenced not only as a Go module, but also by projects that use older tools like `dep` and `govendor`, because the 5.x release of the Go SDK supports either module or non-module usage. Future releases of this package, and of the Go SDK, may drop support for non-module usage.
12-
13-
Also, unlike `go-server-sdk` this does not have `server` in the name, because nothing in this repository is specific to the LaunchDarkly server-side model; it could be used in a client-side context.
9+
Applications using the LaunchDarkly Go SDK will generally use the `ldcontext` subpackage, which contains the `Context` type, and may also use the `ldvalue` package, which contains the `Value` type that represents arbitrary JSON values. Other packages are less frequently used.
1410

1511
## Supported Go versions
1612

17-
This version of the project has been tested with Go 1.14 and higher.
13+
This version of the project has been tested with Go 1.16 and higher.
1814

1915
## Integration with easyjson
2016

@@ -24,7 +20,7 @@ If you do not set the `launchdarkly_easyjson` build tag, `go-sdk-common` does no
2420

2521
## Learn more
2622

27-
Check out our [documentation](http://docs.launchdarkly.com) for in-depth instructions on configuring and using LaunchDarkly. You can also head straight to the [complete reference guide for the Go SDK](http://docs.launchdarkly.com/docs/go-sdk-reference), or the [generated API documentation](https://godoc.org/gopkg.in/launchdarkly/go-sdk-common.v2) for this project.
23+
Check out our [documentation](http://docs.launchdarkly.com) for in-depth instructions on configuring and using LaunchDarkly. You can also head straight to the [complete reference guide for the Go SDK](http://docs.launchdarkly.com/docs/go-sdk-reference), or the [generated API documentation](https://godoc.org/github.com/launchdarkly/go-sdk-common/v3) for this project.
2824

2925
## Contributing
3026

go.mod

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

3-
go 1.13
3+
go 1.16
44

55
require (
6-
github.com/launchdarkly/go-test-helpers/v2 v2.2.0
6+
github.com/launchdarkly/go-jsonstream/v2 v2.0.0
7+
github.com/launchdarkly/go-test-helpers/v2 v2.3.1
78
github.com/mailru/easyjson v0.7.6
89
github.com/stretchr/testify v1.6.1
9-
gopkg.in/launchdarkly/go-jsonstream.v1 v1.0.1
1010
)

go.sum

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
21
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
32
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
43
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
54
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
65
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
7-
github.com/launchdarkly/go-test-helpers/v2 v2.2.0 h1:L3kGILP/6ewikhzhdNkHy1b5y4zs50LueWenVF0sBbs=
8-
github.com/launchdarkly/go-test-helpers/v2 v2.2.0/go.mod h1:L7+th5govYp5oKU9iN7To5PgznBuIjBPn+ejqKR0avw=
6+
github.com/launchdarkly/go-jsonstream/v2 v2.0.0 h1:5NBbJmQAiUVVfAGR6tPuMITGO2+8mxLD0Azyeqgq5Yw=
7+
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=
910
github.com/mailru/easyjson v0.7.6 h1:8yTIVnZgCoiM1TgqoeTl+LfU5Jg6/xL3QhGQnimLYnA=
1011
github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
1112
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
@@ -16,8 +17,6 @@ github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd
1617
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
1718
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
1819
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
19-
gopkg.in/launchdarkly/go-jsonstream.v1 v1.0.1 h1:aZHvMDAS+M6/0sRMkDBQ8MyLGsTQrNgN5evu5e8UYpQ=
20-
gopkg.in/launchdarkly/go-jsonstream.v1 v1.0.1/go.mod h1:YefdBjfITIP8D9BJLVbssFctHkJnQXhv+TiRdTV0Jr4=
2120
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
2221
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
2322
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package sharedtest
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/launchdarkly/go-sdk-common/v3/ldvalue"
7+
)
8+
9+
const (
10+
SmallNumberOfCustomAttributes = 2 //nolint:revive
11+
LargeNumberOfCustomAttributes = 20 //nolint:revive
12+
)
13+
14+
type NameAndLDValue struct { //nolint:revive
15+
Name string
16+
Value ldvalue.Value
17+
}
18+
19+
func MakeCustomAttributeNamesAndValues(count int) []NameAndLDValue { //nolint:revive
20+
ret := make([]NameAndLDValue, 0, count)
21+
for i := 1; i <= count; i++ {
22+
ret = append(ret, NameAndLDValue{fmt.Sprintf("attr%d", i), ldvalue.String(fmt.Sprintf("value%d", i))})
23+
}
24+
return ret
25+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package sharedtest
2+
3+
// These functions return standardized test inputs for unmarshaling JSON user data in the old user schema.
4+
5+
type UnmarshalingTestParams struct { //nolint:revive
6+
Name string
7+
Data []byte
8+
}
9+
10+
func MakeOldUserUnmarshalingTestParams() []UnmarshalingTestParams { //nolint:revive
11+
return []UnmarshalingTestParams{
12+
{"old user with key only", MakeOldUserWithKeyOnlyJSON()},
13+
{"old user with few attrs", MakeOldUserWithFewAttributesJSON()},
14+
{"old user with all attrs", MakeOldUserWithAllAttributesJSON()},
15+
}
16+
}
17+
18+
func MakeOldUserWithKeyOnlyJSON() []byte { //nolint:revive
19+
return []byte(`{"key":"user-key"}`)
20+
}
21+
22+
func MakeOldUserWithFewAttributesJSON() []byte { //nolint:revive
23+
return []byte(`{"key":"user-key","name":"Name","email":"test@example.com","custom":{"attr":"value"}}`)
24+
}
25+
26+
func MakeOldUserWithAllAttributesJSON() []byte { //nolint:revive
27+
return []byte(`{"key":"user-key","secondary":"secondary-value","name":"Name","ip":"ip-value","country":"us",` +
28+
`"email":"test@example.com","firstName":"First","lastName":"Last","avatar":"avatar-value","anonymous":true,` +
29+
`"custom":{"attr":"value"}}`)
30+
}

0 commit comments

Comments
 (0)