Skip to content

Allow any instead of custom *Author type - #1630

Merged
meatballhat merged 2 commits into
mainfrom
author-addr
Jan 2, 2023
Merged

meatballhat merged 2 commits into
mainfrom
author-addr

Conversation

@meatballhat

@meatballhat meatballhat commented Dec 19, 2022 •

Copy link
Copy Markdown
Member

What type of PR is this?

  • cleanup

What this PR does / why we need it:

Drop the custom *Author type and allow any with the assumption that it either implements fmt.Stringer or can otherwise be safely Sprintf'd via %s.

Which issue(s) this PR fixes:

Supports #1586 given the *Author type was defined in app.go which is slated for removal.

@meatballhat meatballhat added this to the Release 3.x milestone Dec 19, 2022
@meatballhat
meatballhat requested a review from a team as a code owner December 19, 2022 03:01
@meatballhat meatballhat mentioned this pull request Dec 19, 2022
asahasrabuddhe
asahasrabuddhe previously approved these changes Dec 19, 2022

@asahasrabuddhe asahasrabuddhe 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.

This looks good. Why are the tests failing though?

@abitrolly

abitrolly commented Dec 19, 2022 •

Copy link
Copy Markdown
Contributor

@asahasrabuddhe looks like net/mail adds 500kB to the size of the package.

@meatballhat

Copy link
Copy Markdown
Member Author

@asahasrabuddhe @abitrolly I introduced this because I generally consider using an existing standard library type to be preferable to maintaining our own. Considering the increase in binary size, and that we're not going to be attempting to directly send email with the result of *mail.Address.String, I'm leaning towards not making this change. WDYT?

@abitrolly

Copy link
Copy Markdown
Contributor

@meatballhat I think like this issue needs to be addressed upstream somehow. Implementing interface for storing two strings should not result in 500kB increase. Why does this happen?

@meatballhat

Copy link
Copy Markdown
Member Author

@meatballhat I think like this issue needs to be addressed upstream somehow. Implementing interface for storing two strings should not result in 500kB increase. Why does this happen?

@abitrolly wow, yeah, I hadn't thought of it that way!

@asahasrabuddhe

Copy link
Copy Markdown
Member

This change does not make sense considering the increase in binary size. If we find a way like implementing an interface which is still compatible with the standard library and also does not affect the binary size, that's the way to go.

@dearchap

Copy link
Copy Markdown
Contributor

@meatballhat Just revert to old struct it was just 2 fields. Simple and direct or make an interface and add an example in docs of how to use mail.Address with it.

@meatballhat

Copy link
Copy Markdown
Member Author

@dearchap I think now that I'd like to use Authors []any given that the values are only ever passed to Sprintf-like functions with %s anyway. I'd like to keep reducing the surface area as much as possible, and making such a change would support that effort. WDYT?

@dearchap

dearchap commented Jan 1, 2023

Copy link
Copy Markdown
Contributor

@meatballhat That would be fine.

and updated tests to use both strings and *mail.Address
@meatballhat meatballhat changed the title Use *mail.Address instead of custom *Author type Allow any instead of custom *Author type Jan 1, 2023
@meatballhat
meatballhat requested review from a team and asahasrabuddhe January 1, 2023 22:39
@meatballhat
meatballhat merged commit 97854d2 into main Jan 2, 2023
@meatballhat
meatballhat deleted the author-addr branch January 2, 2023 21:26
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.

4 participants