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 panic on empty interface field #40

Merged

Conversation

leonid-shevtsov
Copy link
Contributor

@leonid-shevtsov leonid-shevtsov commented Sep 10, 2024

Description

You cannot call reflect.ValueOf(nilInterface).Type() - because a nil interface has no type. It panics with

panic: reflect: call of reflect.Value.Type on zero Value

The resolution is to check whether the value is an empty value. I decided that it makes sense to render it as nil because it's equatable to nil within the program.

Checklist

  • Code compiles correctly
  • Created tests which fail without the change
  • All tests passing
  • Extended the README / documentation, if necessary

@david-littlefarmer
Copy link
Collaborator

Thanks for fix 🙏

@david-littlefarmer david-littlefarmer merged commit dd7530d into golang-cz:master Sep 11, 2024
1 check passed
@leonid-shevtsov leonid-shevtsov deleted the fix-empty-interface-field branch September 12, 2024 08:53
renovate bot referenced this pull request in jippi/dottie Sep 20, 2024
…o.mod (#97)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[github.com/golang-cz/devslog](https://redirect.github.com/golang-cz/devslog)
| `v0.0.9` -> `v0.0.11` |
[![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fgolang-cz%2fdevslog/v0.0.11?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fgolang-cz%2fdevslog/v0.0.11?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fgolang-cz%2fdevslog/v0.0.9/v0.0.11?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fgolang-cz%2fdevslog/v0.0.9/v0.0.11?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>golang-cz/devslog (github.com/golang-cz/devslog)</summary>

###
[`v0.0.11`](https://redirect.github.com/golang-cz/devslog/releases/tag/v0.0.11)

[Compare
Source](https://redirect.github.com/golang-cz/devslog/compare/v0.0.10...v0.0.11)

#### What's Changed

- fix nilString after rebase by
[@&#8203;david-littlefarmer](https://redirect.github.com/david-littlefarmer)
in
[https://github.com/golang-cz/devslog/pull/41](https://redirect.github.com/golang-cz/devslog/pull/41)

**Full Changelog**:
golang-cz/devslog@v0.0.10...v0.0.11

###
[`v0.0.10`](https://redirect.github.com/golang-cz/devslog/releases/tag/v0.0.10):
- Broken

[Compare
Source](https://redirect.github.com/golang-cz/devslog/compare/v0.0.9...v0.0.10)

Broken, use v0.0.11

#### What's Changed

- Remove sync.Mutex pointer by
[@&#8203;VojtechVitek](https://redirect.github.com/VojtechVitek) in
[https://github.com/golang-cz/devslog/pull/37](https://redirect.github.com/golang-cz/devslog/pull/37)
- Fix panic on empty interface field by
[@&#8203;leonid-shevtsov](https://redirect.github.com/leonid-shevtsov)
in
[https://github.com/golang-cz/devslog/pull/40](https://redirect.github.com/golang-cz/devslog/pull/40)
- No color by
[@&#8203;david-littlefarmer](https://redirect.github.com/david-littlefarmer)
in
[https://github.com/golang-cz/devslog/pull/39](https://redirect.github.com/golang-cz/devslog/pull/39)

#### New Contributors

- [@&#8203;leonid-shevtsov](https://redirect.github.com/leonid-shevtsov)
made their first contribution in
[https://github.com/golang-cz/devslog/pull/40](https://redirect.github.com/golang-cz/devslog/pull/40)

**Full Changelog**:
golang-cz/devslog@v0.0.9...v0.0.10

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "* */1 * * *" (UTC), 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 was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/jippi/dottie).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC44MC4wIiwidXBkYXRlZEluVmVyIjoiMzguODAuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiZGVwZW5kZW5jaWVzIl19-->

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.

2 participants