Skip to content

Releases: stretchr/objx

v0.8.0

Choose a tag to compare

@hanzei hanzei released this 14 Oct 14:05
3af36f9

New features

  • Map.Delete removes values by selector. It takes one or more selectors in the same dot and bracket notation as Get and Set, removes the map keys or slice elements they point to, and returns the map so calls can be chained:

    m.Delete("books[1].chapters[2].title", "draft")

    Selectors run in order, so after a slice element is removed, later selectors see the shifted indexes. Missing paths and out-of-range indexes are ignored. Removing a slice element builds a new slice of the same type ([]string stays []string) and leaves the original backing array untouched. Maps along the path are modified in place. (#174)

What's Changed

  • feat: add Delete method to Map by selector by @00200200 in #174

New Contributors

Full Changelog: v0.7.0...v0.8.0

v0.7.0

Choose a tag to compare

@hanzei hanzei released this 13 Oct 07:34
be9331c

Upgrade notes

Behavior changes

  • Has now reports keys whose value is nil. Map.Has used to return false both for missing keys and for keys set to nil, so the two couldn't be told apart. It now returns true whenever the selector exists, including nested keys, bracket keys and slice indexes that hold nil. If you relied on Has to mean "set and not nil", use !m.Get(selector).IsNil() instead. (#172)

Other

  • Added a contributing guide (#183), a security policy (#182) and issue templates (#184).
  • The Go workflow token is now restricted to read-only contents (#181).

What's Changed

  • Restrict the Go workflow token to read-only contents by @hanzei in #181
  • Add a security policy by @hanzei in #182
  • Add a contributing guide by @hanzei in #183
  • Add bug report and feature request issue templates by @hanzei in #184
  • Differentiate nil values from missing keys in Map.Has by @AdamMagued in #172

New Contributors

Full Changelog: v0.6.0...v0.7.0

v0.6.0

Choose a tag to compare

@hanzei hanzei released this 13 Oct 07:10
7c54053

Upgrade notes

Go 1.25 or later is now required (previously Go 1.20). (#175)

Behavior changes

  • Where* now returns the items the decider selects. Previously every Where* method (WhereInt, WhereStr, WhereMSI, WhereObjxMap, …) returned the items for which the decider returned false, the opposite of what its documentation says. If you negated your decider to work around this, remove the negation. (#180)
  • Indexed Set updates the element instead of replacing the slice. Set("names[0]", "Mat") used to replace the whole names slice with "Mat"; it now sets only the first element. Indexing into a value that isn't a slice (e.g. Get("name[0]") on a string) now returns a missing value instead of the value itself. (#170)
  • Nil slices and maps stay null in JSON. objx.Map{"items": []any(nil)} now encodes as {"items":null} instead of {"items":[]}. Empty, non-nil containers still encode as [] / {}. (#171)
  • URLValues keeps every element of a slice of maps. With the [] and "" key suffixes, only the last element's values used to be kept. []any values (e.g. arrays decoded from JSON) are now encoded element by element instead of as a Go-syntax string. (#177)
  • The error returned by SetURLValuesSliceKeySuffix for an invalid suffix now reads objx: invalid URLValuesSliceKeySuffix provided. (#176)

Other

  • The API now uses any instead of interface{}. They are the same type, so this doesn't affect callers. (#175)
  • The type-specific accessors are now generated with go generate (#179), and CI runs golangci-lint (#176, #178).

What's Changed

  • Bump actions/checkout from 5 to 6 by @dependabot[bot] in #163
  • Fix flaky TestConversionURLValues when run with -shuffle by @hanzei in #165
  • Bump go-task/setup-task from 1 to 2 by @dependabot[bot] in #166
  • Bump actions/checkout from 6 to 7 by @dependabot[bot] in #167
  • Bump actions/setup-go from 6 to 7 by @dependabot[bot] in #168
  • Preserve slices when setting an indexed value by @vitalivo in #170
  • Preserve null values when converting nil containers to JSON by @x0Lazarus in #171
  • Modernize: use any, require Go 1.25, apply go fix by @hanzei in #175
  • Add golangci-lint and run it in CI by @hanzei in #176
  • Enable more linters and the gofumpt and goimports formatters by @hanzei in #178
  • Cover nested URL values and keep repeated map-slice entries by @hanzei in #177
  • Replace the browser-based codegen with go generate by @hanzei in #179
  • Fix Where* returning the items the decider rejected by @hanzei in #180

New Contributors

Full Changelog: v0.5.3...v0.6.0

v0.5.3

Choose a tag to compare

@hanzei hanzei released this 07 Oct 09:06
b152998

What's Changed

New Contributors

Full Changelog: v0.5.2...v0.5.3

v0.5.2

Choose a tag to compare

@hanzei hanzei released this 29 Feb 09:59
307d0db

What's Changed

Full Changelog: v0.5.1...v0.5.2

v0.5.1

Choose a tag to compare

@hanzei hanzei released this 08 Aug 12:03
65e87f4

What's Changed

New Contributors

  • @autarch made their first contribution in #128. Thank you for your contribution!
  • @alexandear made their first contribution in #129. Thank you for your contribution!
  • @dolmen made their first contribution in #139. Thank you for your contribution!

Full Changelog: v0.5.0...v0.5.1

v0.5.0

Choose a tag to compare

@geseq geseq released this 15 Oct 03:19
50a2c06

v0.4.0

Choose a tag to compare

@geseq geseq released this 08 May 11:03
5dbb4e6

v0.3.0

Choose a tag to compare

@geseq geseq released this 15 Jul 08:16

Enhancements

Fixes

v0.2.0

Choose a tag to compare

@hanzei hanzei released this 09 Apr 12:34
ea4fe68

Notes

This release drops the support for go version less then 1.10.

Enhancements

Fixes