Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace internal joined error with errors.Join #25

Merged
merged 3 commits into from
Jun 2, 2024
Merged

Conversation

sagikazarmark
Copy link
Member

As preparation to Go 1.20 requirement, this PR backports some code from the Go stdlib and uses errors.Join to join multiple errors together.

It's a backward incompatible change in the sense that the error output becomes different:

  • No more asterisks to denote error items (following errors.Join)
  • No more error sorting

As an attempt to preserve some of the original behavior, Decoder.Decode continues to return errors in the following format (when multiple errors occur):

decoding failed due to the following error(s):

'Name' expected type 'string', got unconvertible type 'int', value: '123'
'Age' expected type 'int', got unconvertible type 'string', value: 'bad value'
'Emails[0]' expected type 'string', got unconvertible type 'int', value: '1'
'Emails[1]' expected type 'string', got unconvertible type 'int', value: '2'
'Emails[2]' expected type 'string', got unconvertible type 'int', value: '3'

This may change in the future

Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
@sagikazarmark sagikazarmark added the enhancement New feature or request label Jun 2, 2024
@sagikazarmark sagikazarmark merged commit 35d054a into main Jun 2, 2024
8 checks passed
@sagikazarmark sagikazarmark deleted the error branch June 2, 2024 08:31
nono referenced this pull request in cozy/cozy-stack Jun 3, 2024
#4415)

[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[github.com/go-viper/mapstructure/v2](https://togithub.com/go-viper/mapstructure)
| `v2.0.0-alpha.1` -> `v2.0.0` |
[![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fgo-viper%2fmapstructure%2fv2/v2.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fgo-viper%2fmapstructure%2fv2/v2.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fgo-viper%2fmapstructure%2fv2/v2.0.0-alpha.1/v2.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fgo-viper%2fmapstructure%2fv2/v2.0.0-alpha.1/v2.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>go-viper/mapstructure
(github.com/go-viper/mapstructure/v2)</summary>

###
[`v2.0.0`](https://togithub.com/go-viper/mapstructure/releases/tag/v2.0.0)

[Compare
Source](https://togithub.com/go-viper/mapstructure/compare/v2.0.0-alpha.1...v2.0.0)

### mapstructure v2 release 🎉🎉🎉🎉

#### ⚠️ Breaking changes

- `Error` is removed in favor of `errors.Join` (backported from Go 1.20
to preserve compatibility with earlier versions)

#### What's Changed

- feat!: update module path by
[@&#8203;sagikazarmark](https://togithub.com/sagikazarmark) in
[https://github.com/go-viper/mapstructure/pull/9](https://togithub.com/go-viper/mapstructure/pull/9)
- build: update dev env by
[@&#8203;sagikazarmark](https://togithub.com/sagikazarmark) in
[https://github.com/go-viper/mapstructure/pull/14](https://togithub.com/go-viper/mapstructure/pull/14)
- feature: add StringToBasicTypeHookFunc and support complex by
[@&#8203;tlipoca9](https://togithub.com/tlipoca9) in
[https://github.com/go-viper/mapstructure/pull/13](https://togithub.com/go-viper/mapstructure/pull/13)
- Add an example showing how to use a DecodeHookFunc to parse a custom …
by [@&#8203;carlohamalainen](https://togithub.com/carlohamalainen) in
[https://github.com/go-viper/mapstructure/pull/10](https://togithub.com/go-viper/mapstructure/pull/10)
- Remove exposed error type by
[@&#8203;sagikazarmark](https://togithub.com/sagikazarmark) in
[https://github.com/go-viper/mapstructure/pull/24](https://togithub.com/go-viper/mapstructure/pull/24)
- Replace internal joined error with errors.Join by
[@&#8203;sagikazarmark](https://togithub.com/sagikazarmark) in
[https://github.com/go-viper/mapstructure/pull/25](https://togithub.com/go-viper/mapstructure/pull/25)
- Prepare release by
[@&#8203;sagikazarmark](https://togithub.com/sagikazarmark) in
[https://github.com/go-viper/mapstructure/pull/23](https://togithub.com/go-viper/mapstructure/pull/23)

#### New Contributors

- [@&#8203;tlipoca9](https://togithub.com/tlipoca9) made their first
contribution in
[https://github.com/go-viper/mapstructure/pull/13](https://togithub.com/go-viper/mapstructure/pull/13)
- [@&#8203;carlohamalainen](https://togithub.com/carlohamalainen) made
their first contribution in
[https://github.com/go-viper/mapstructure/pull/10](https://togithub.com/go-viper/mapstructure/pull/10)

**Full Changelog**:
go-viper/mapstructure@v1.6.0...v2.0.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 6am on Monday" in timezone
Europe/Paris, Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/cozy/cozy-stack).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zNzcuOCIsInVwZGF0ZWRJblZlciI6IjM3LjM3Ny44IiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIiwibGFiZWxzIjpbXX0=-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant