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

fix: skip encoding an inline field if it is null #386

Merged
merged 1 commit into from
Sep 13, 2023
Merged

Conversation

zoncoen
Copy link
Contributor

@zoncoen zoncoen commented Sep 13, 2023

The current implementation returns an error if an inline field is null. This PR makes skipping encoding null inline fields.

This behavior is the same as encoding/json.

b, err := json.Marshal(struct {
	*base `yaml:",inline"`
	C     bool
}{
	C: true,
})
if err != nil {
	panic(err)
}
fmt.Println(string(b))

=> {"C":true}

@codecov-commenter
Copy link

Codecov Report

Merging #386 (d90e6f3) into master (42fb764) will increase coverage by 0.05%.
The diff coverage is 100.00%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #386      +/-   ##
==========================================
+ Coverage   75.61%   75.66%   +0.05%     
==========================================
  Files          13       13              
  Lines        4650     4652       +2     
==========================================
+ Hits         3516     3520       +4     
+ Misses        874      873       -1     
+ Partials      260      259       -1     

@goccy
Copy link
Owner

goccy commented Sep 13, 2023

Thank you for your great PR !! LGTM 👍

@goccy goccy merged commit f5c5711 into goccy:master Sep 13, 2023
18 checks passed
@zoncoen zoncoen deleted the inline branch September 13, 2023 08:18
renovate bot added a commit to anoriqq/qpm that referenced this pull request Sep 14, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [github.com/goccy/go-yaml](https://togithub.com/goccy/go-yaml) |
require | patch | `v1.11.0` -> `v1.11.1` |

---

### Release Notes

<details>
<summary>goccy/go-yaml (github.com/goccy/go-yaml)</summary>

###
[`v1.11.1`](https://togithub.com/goccy/go-yaml/releases/tag/v1.11.1):
1.11.1

[Compare
Source](https://togithub.com/goccy/go-yaml/compare/v1.11.0...v1.11.1)

#### What's Changed

- Handle `\r` in a double-quoted string the same as `\n` by
[@&#8203;k1LoW](https://togithub.com/k1LoW) in
[goccy/go-yaml#372
- chore: replace loop with n.Values = append(n.Values, target.Values...)
by [@&#8203;testwill](https://togithub.com/testwill) in
[goccy/go-yaml#380
- fix: skip encoding an inline field if it is null by
[@&#8203;zoncoen](https://togithub.com/zoncoen) in
[goccy/go-yaml#386
- Fix comment parsing with null value by
[@&#8203;goccy](https://togithub.com/goccy) in
[goccy/go-yaml#388

#### New Contributors

- [@&#8203;testwill](https://togithub.com/testwill) made their first
contribution in
[goccy/go-yaml#380

**Full Changelog**:
goccy/go-yaml@v1.11.0...v1.11.1

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **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/anoriqq/qpm).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi44My4wIiwidXBkYXRlZEluVmVyIjoiMzYuODMuMCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants