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

Add unified number parsing functions in sources #8

Merged
merged 1 commit into from
Jul 1, 2021

Conversation

na--
Copy link
Member

@na-- na-- commented Jul 1, 2021

This preserves the completely type-safe "frontends" (i.e. Field constructors like NewInt64Field(dest *int64, ...)), but makes the job of implementing a Source much simpler. By using the biggest types, we don't need to implement a method for every single base Go number type (int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64, byte, float32, float64), instead just 3 (int64, uint64, float64) and some extra validation.

@na-- na-- requested review from artych and codebien July 1, 2021 11:39
if err != nil {
return err
func (cb *cliBinding) BindIntValue() func(bitSize int) (int64, error) {
if cb.position > 0 {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't find a nice way to avoid this repetition with pflag 😞

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My PR is changing that part so I will take care of it

Copy link
Contributor

@artych artych left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice refactoring! LGTM
I'd propose we merge this and I can embed that to basic types within my basic types PR

@na-- na-- merged commit 1d0934d into main Jul 1, 2021
@na-- na-- deleted the unified-number-sources branch July 1, 2021 17:30
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