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 WithContext versions of functions that use contexts. #555

Merged
merged 3 commits into from
Jan 9, 2025

Conversation

marksuter
Copy link
Contributor

These new functions are equivalent, but allow callers to pass a context down from main (or equivalent). This is necessary to comply with certain style guides, for example, https://google.github.io/styleguide/go/decisions#contexts.

We considered replacing dhcpv4.GenerateTransactionID with rand.Read(xid[:]) based on the godoc saying that Read call "never returns an error", but this package is used in embedded situations where it can fail.

// won't be a valid DHCPv4 message so you will need to adjust its fields.
// See also NewDiscovery, NewRequest, NewAcknowledge, NewInform and NewRelease.
// won't be a valid DHCPv4 message so you will need to adjust its fields. See
// also NewDiscovery, NewRequest, NewAcknowledge, NewInform and NewRelease.
func New(modifiers ...Modifier) (*DHCPv4, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you make New be a wrapper of NewWithContext as well? just so changes to one aren't forgotten in the other.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done with e0b42be.

These new functions are equivalent, but allow callers to pass a context down from main (or equivalent).  This is necessary to comply with certain style guides, for example, https://google.github.io/styleguide/go/decisions#contexts.

We considered replacing dhcpv4.GenerateTransactionID with rand.Read(xid[:]) based on the godoc saying that Read call "never returns an error", but this package is used in embedded situations where it can fail.

Signed-off-by: Mark Suter <[email protected]>
hugelgupf
hugelgupf previously approved these changes Jan 9, 2025
@hugelgupf hugelgupf merged commit 8abf581 into insomniacslk:master Jan 9, 2025
7 checks passed
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.

2 participants