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

feat: Use generics to get pointers to types #219

Merged
merged 1 commit into from Dec 20, 2022

Conversation

daenney
Copy link
Contributor

@daenney daenney commented Dec 19, 2022

Since the minimum required Go version is 1.18 according to go.mod we can use generics to have a single function that can return a pointer to any type. This avoids the need to add more $Type helpers in the future.

The new Ptr function is introduced and exsiting functions are updated to call through Ptr instead. Any exported functions are now marked as deprecated but not removed in order to avoid breaking backwards compatibility. All non-exported functions are removed. All call sites are updated to use Ptr directly.

@apricote
Copy link
Member

Thanks for the contribution @daenney!

We still test against Go 1.17, even though the go.mod specifies v1.18+.

We should remove the tests for Go v1.17 and codify our Go version requirements (probably in line with official support).

I will create a PR for this and notify you once that is merged :)

@apricote
Copy link
Member

#220 is merged, you may now rebase your branch against main.

@apricote apricote self-requested a review December 20, 2022 07:36
Since the minimum required Go version is 1.18 according to go.mod we can
use generics to have a single function that can return a pointer to any
type. This avoids the need to add more $Type helpers in the future.

The new Ptr function is introduced and exsiting functions are updated to
call through Ptr instead. Any exported functions are now marked as
deprecated but not removed in order to avoid breaking backwards
compatibility. All non-exported functions are removed. All call sites
are updated to use Ptr directly.
@daenney
Copy link
Contributor Author

daenney commented Dec 20, 2022

@apricote Thanks! Pushed a rebase.

@apricote apricote merged commit a5cd797 into hetznercloud:main Dec 20, 2022
@daenney daenney deleted the generic-ptr branch December 20, 2022 09:39
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

2 participants