Skip to content

Conversation

dearchap
Copy link
Contributor

@dearchap dearchap commented Oct 2, 2022

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
Copy link

jtagcat commented Oct 8, 2022

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
Copy link

jtagcat commented Oct 8, 2022

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

@dearchap
Copy link
Contributor Author

dearchap commented Oct 8, 2022

Not sure, it wasnt a direct import

@jtagcat
Copy link

jtagcat commented Oct 8, 2022

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.

@jtagcat
Copy link

jtagcat commented Nov 13, 2022

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

@jtagcat
Copy link

jtagcat commented Nov 13, 2022

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
meatballhat
meatballhat previously approved these changes Nov 17, 2022
meatballhat
meatballhat previously approved these changes Nov 26, 2022
Copy link
Member

@meatballhat meatballhat left a comment

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! 🎉

@dearchap dearchap merged commit aef9126 into urfave:main Nov 26, 2022
@meatballhat meatballhat mentioned this pull request Nov 27, 2022
18 tasks
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