Skip to content

First cut at using generics for base flag types - #1512

Merged
dearchap merged 32 commits into
urfave:mainfrom
dearchap:use_generics
Nov 26, 2022
Merged

dearchap merged 32 commits into
urfave:mainfrom
dearchap:use_generics

Conversation

@dearchap

@dearchap dearchap commented Oct 2, 2022 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

(REQUIRED)

  • cleanup

What this PR does / why we need it:

(REQUIRED)

Use generics all the way

Which issue(s) this PR fixes:

(REQUIRED)

Connected to #833

Special notes for your reviewer:

(fill-in or delete this section)

Testing

(fill-in or delete this section)

Release Notes

(REQUIRED)


@jtagcat

jtagcat commented Oct 8, 2022 •

Copy link
Copy Markdown

iirc using generics lessens type checking, and moves errors to runtime, but it might work as a wrapper to a flag lib itself

I have a weekend, I'll try to review this or work on harg..

@jtagcat

jtagcat commented Oct 8, 2022

Copy link
Copy Markdown

What were you experimenting with golang.org/x/exp?

@dearchap

dearchap commented Oct 8, 2022

Copy link
Copy Markdown
Contributor Author

Not sure, it wasnt a direct import

@jtagcat

jtagcat commented Oct 8, 2022 •

Copy link
Copy Markdown

I can't yet put my finger on it, but be aware, that multiple interface typing (interface{}.(type).(int)) will panic if the larger type is not found, under a if v, ok := .

if v, ok := resolves panic / gives ok value only on the last .(int). If anything before it is not found, it will panic.

edit: this seems to not be a problem in this source, it's the hacks with stdlib/flag, that made me feel it


edit2: I think I don't have much more to add atm, I'd rather go work on harg, or something else on my list.

Comment thread app_test.go Resolved
@jtagcat

jtagcat commented Nov 13, 2022

Copy link
Copy Markdown

jfyi generics are not the keyword here, what you/we are doing is implementing/using (generic) interfaces

@jtagcat

jtagcat commented Nov 13, 2022

Copy link
Copy Markdown

I'd move flags to a separate subpackage (a subdirectory), this would most importantly isolate it, but also enable possible external uses.

@dearchap
dearchap marked this pull request as ready for review November 13, 2022 20:21
@dearchap
dearchap requested a review from a team as a code owner November 13, 2022 20:21
@dearchap
dearchap changed the base branch from v3-dev-main to main November 13, 2022 20:22
Comment thread docs_test.go Resolved
meatballhat
meatballhat previously approved these changes Nov 17, 2022
Comment thread flag_impl.go Resolved
Comment thread flag_impl.go Resolved
Comment thread flag_string.go Resolved
Comment thread sliceflag.go Resolved
meatballhat
meatballhat previously approved these changes Nov 26, 2022

@meatballhat meatballhat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nits only! This is very exciting! 🎉

Comment thread flag_slice_impl.go Resolved
Comment thread flag_slice_impl.go Resolved
Comment thread flag_slice_impl.go Resolved
Comment thread flag_slice_impl.go Resolved
Comment thread flag_slice_impl.go Resolved
Comment thread flag_timestamp.go Resolved
Comment thread flag_uint.go Resolved
Comment thread flag_uint64.go Resolved
@dearchap
dearchap merged commit aef9126 into urfave:main Nov 26, 2022
@meatballhat meatballhat mentioned this pull request Nov 27, 2022
18 tasks done
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.

3 participants