moov-io / iso8583

A golang implementation to marshal and unmarshal iso8583 message.
https://moov.io
Apache License 2.0
306 stars 100 forks source link

field: nil check Numeric, String, Composite, etc accessors #196

Closed adamdecaf closed 1 year ago

adamdecaf commented 1 year ago

Issue: https://github.com/moov-io/iso8583/issues/195

codecov-commenter commented 1 year ago

Codecov Report

Base: 71.21% // Head: 71.30% // Increases project coverage by +0.08% :tada:

Coverage data is based on head (3940453) compared to base (68aee25). Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #196 +/- ## ========================================== + Coverage 71.21% 71.30% +0.08% ========================================== Files 40 40 Lines 1845 1847 +2 ========================================== + Hits 1314 1317 +3 + Misses 340 339 -1 Partials 191 191 ``` | [Impacted Files](https://codecov.io/gh/moov-io/iso8583/pull/196?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=moov-io) | Coverage Δ | | |---|---|---| | [field/string.go](https://codecov.io/gh/moov-io/iso8583/pull/196/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=moov-io#diff-ZmllbGQvc3RyaW5nLmdv) | `77.33% <100.00%> (+1.99%)` | :arrow_up: | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=moov-io). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=moov-io)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

alovak commented 1 year ago

This is a really good change to make code simpler for the callers

adamdecaf commented 1 year ago

@alovak Cool. I can add this to every field type.

alovak commented 1 year ago

thanks @adamdecaf! this PR looks 💪

the only thing that (kind of) worries me is that GetValue. On message we have GetString(), GetBytes(). But on field we have String() and Bytes() and now we add GetValue().

We can introduce a breaking change by adding Value() and SetValue() and renaming Value into value. It will make code more consistent and safe. In my personal opinion, such change is just find/replace so it should not be a PITA.

thoughts?

adamdecaf commented 1 year ago

Yea I agree that GetValue() isn't idea and I'm okay with that breaking change. It's minor enough and increases runtime safety.

adamdecaf commented 1 year ago

@alovak feel free to merge this whenever you want. I know there are other 8583 changes in flight.