All notable changes to the project will be documented in this file. This project adheres to Semantic Versioning.
3.2.0 (2024-10-21)
- Introduced ldmigration and ldsampling utility packages to support technology migration use cases.
- Fixed unmarshaling bug in easyJSON implementation when
privateAttributes
orredactedAttributes
were encountered in Context_meta
attribute, but not expected.
This major version release of go-sdk-common
corresponds to the upcoming v6.0.0 release of the LaunchDarkly Go SDK (go-server-sdk
), and cannot be used with earlier SDK versions.
- The new package
ldcontext
with the typesContext
andKind
defines the new "context" model. "Contexts" are a replacement for the earlier concept of "users"; they can be populated with attributes in more or less the same way as before, but they also support new behaviors. More information about these features will be included in the release notes for the v6.0.0 SDK release. - The new package
ldattr
defines the attribute reference syntax, for referencing subproperties of JSON objects in flag evaluations or private attribute configuration. Applications normally will not need to reference this package.
- The minimum Go version is now 1.18.
- The SDK packages now use regular Go module import paths rather than
gopkg.in
paths:gopkg.in/launchdarkly/go-sdk-common.v2
is replaced bygithub.com/launchdarkly/go-sdk-common/v3
. - The type
lduser.User
has been redefined to be an alias forldcontext.Context
. This means that existing application code referencinglduser.User
can still work as long as it is treating the user as an opaque value, and not calling methods on it that were specific to that type. lduser.NewUser
andlduser.UserBuilder
now create an instance ofContext
instead ofUser
. This is as a convenience so that any code that was previously using these methods to construct a user, but did not reference theUser
type directly for the result, may still be usable without changes. It is still preferable to use the new constructors and builders forContext
.- The
Secondary
attribute which existed inUser
does not exist inContext
and is no longer a supported feature. - It was previously allowable to set a user key to an empty string. In the new context model, the key is not allowed to be empty. Trying to use an empty key will cause evaluations to fail and return the default value.
- If you were using JSON serialization to produce a representation of a
User
, the new typeContext
uses a different JSON schema, so any code that reads the JSON will need to be adjusted. If you are passing the JSON to other code that uses LaunchDarkly SDKs, make sure you have updated all SDKs to versions that use the new context model. (However, unmarshaling aContext
from JSON data will still work correctly even if the JSON is in the old user format.)
- Removed the
Secondary
meta-attribute inlduser.UserBuilder
.
- If you create an
ldvalue.Value
with theldvalue.Raw(json.RawMessage)
constructor, and you pass a zero-length or nil value to the constructor, and then encode theValue
to JSON withjson.Marshal
or an equivalent method, the JSON output will now benull
(that is, the literal charactersnull
representing a JSON null value). Previously it would have been a zero-length string, which is not valid as the JSON encoding of any value and could cause the SDK to output a malformed JSON document if the document contained such a value.
This release was unintended and can be ignored. It contains no code changes, only changes to the CI build.
- In
ldreason
, added new optional status information related to the new big segments feature.
- The SDK now supports the ability to control the proportion of traffic allocation to an experiment. This works in conjunction with a new platform feature now available to early access customers.
- Updated
go-jsonstream
to v1.0.1 to incorporate a bugfix in JSON number parsing.
- Greatly improved the efficiency of deserializing
lduser
andldvalue
types from JSON when thelaunchdarkly_easyjson
build tag is enabled, by using the EasyJSON API more directly than before. When the build tag is not enabled, these changes have no effect.
- Parsing a
User
from JSON failed if there was aprivateAttributeNames
property whose value wasnull
. This has been fixed so that it behaves the same as if the property had a value of[]
or if it was not present at all.
- All types that can be converted to or from JSON now have
WriteToJSONWriter
andReadFromJSONReader
methods that use the newgo-jsonstream
API for greater efficiency, althoughjson.Marshal
andjson.Unmarshal
still also work.
- The
jsonstream
subpackage ingo-sdk-common
is now deprecated in favor ofgo-jsonstream
. The Go SDK no longer usesjsonstream
, but it is retained here for backward compatibility with any other code that may have been using it. Some types still haveWriteToJSONBuffer
methods for usingjsonstream
; these are also deprecated.
IsDefined()
method forldvalue.Value
,ldreason.EvaluationReason
, andldtime.UnixMillisecondTime
.ValueArray
andValueMap
types inldvalue
, for representing immutable JSON array/object data in contexts where only an array or an object is allowed, as opposed to the more generalldvalue.Value
. This is mainly used by LaunchDarkly internal components but may be useful elsewhere.
- In
lduser.NewUserBuilderFromUser()
, if the original user had custom attributes and/or private attributes, the map that holds that data now has copy-on-write behavior: that is, the builder will only allocate a new map if you actually make changes to those attributes.
- Trying to unmarshal a JSON
null
value intolduser.User
now returns an error of type*json.UnmarshalTypeError
, rather than misleadingly returninglduser.ErrMissingKey()
. - Trying to unmarshal a JSON value of the wrong type into
ldvalue.OptionalBool
,ldvalue.OptionalInt
, orldvalue.OptionalString
now returns an error of type*json.UnmarshalTypeError
, rather than a generic error string fromerrors.New()
. - The error
lduser.ErrMissingKey()
had an empty error string.
Initial release of the newer types that will be used in Go SDK 5.0 and above.
- Package
ldlog
, which was formerly a subpackage ofgo-server-sdk
. - Package
ldlogtest
, containing test helpers for use withldlog
. - Package
ldreason
, containingEvaluationReason
and related types that were formerly ingo-server-sdk
. - Package
ldtime
, containingUnixMillisecondTime
. - Package
lduser
, containingUser
and related types that were formerly ingo-server-sdk
. - Package
jsonstream
, a fast JSON encoding tool that is used internally by the SDK. ldvalue.OptionalString
now implementsencoding.TextMarshaler
andencoding.TextUnmarshaler
. This is not used by the Go SDK, but can be helpful when usingOptionalString
in other contexts.ldvalue.OptionalBool
andldvalue.OptionalInt
are analogous toldvalue.OptionalString
, representing values that may be undefined without using pointers. These are used in the Go SDK.
- The minimum Go version is now 1.14.
- The
User
type is now opaque and immutable; there is no direct access to its fields. - The
User
type no longer uses pointers orinterface{}
internally, decreasing the need for heap allocations. - Reading a
User
from JSON withjson.Unmarshal
now returns an error if thekey
property is missing or null. EvaluationDetail.VariationIndex
is now anOptionalInt
rather than anint
.EvaluationReason
is now a struct.- This project is now a Go module, although it can still be used from non-module code.
- In
ldvalue
, there are no longer methods for wrapping an existinginterface{}
value in aValue
. - All deprecated members of types that were moved here from
go-server-sdk
have been removed.
Initial release. This will be used in versions 4.16.0 and above of the LaunchDarkly Server-Side SDK for Go.