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

proposal: time: add At function #25892

Closed
roy2220 opened this issue Jun 14, 2018 · 5 comments

Comments

Projects
None yet
4 participants
@roy2220
Copy link

commented Jun 14, 2018

Before:

select {
    case <-c:
        ...
    case <-time.After(time.Until(deadline)):
        ...
}

After:

select {
    case <-c:
        ...
    case <-time.At(deadline):
        ...
}

@roy2220 roy2220 changed the title time: add At method time: add At function Jun 14, 2018

@agnivade

This comment has been minimized.

Copy link
Member

commented Jun 14, 2018

Please have a look at https://golang.org/s/proposal. Ensure that you mention why adding a new function will benefit users. Real world examples are appreciated. If this is just about saving a few keystrokes, the reason should be justified sufficiently.

Kindly update the issue accordingly. Thanks.

@mvdan

This comment has been minimized.

Copy link
Member

commented Jun 14, 2018

Also note that this has been rejected in the past: #2729

Unless there are points in its favor that weren't made in that previous issue, it's likely that this issue will be closed as a duplicate.

@mvdan

This comment has been minimized.

Copy link
Member

commented Jun 14, 2018

Another point in favor of rejection is that the workaround is simpler than it used to be. The original issue suggested time.After(when.Sub(time.Now())), while you can do time.After(time.Until(when)) now.

@roy2220

This comment has been minimized.

Copy link
Author

commented Jun 14, 2018

@agnivade @mvdan In my case, I prefer deadline to timeout when designing interface, As https://golang.org/pkg/net/#TCPConn.SetDeadline, https://golang.org/pkg/context/#WithDeadline do. I think deadline should be treated "equally".

@andybons andybons changed the title time: add At function proposal: time: add At function Jun 14, 2018

@gopherbot gopherbot added this to the Proposal milestone Jun 14, 2018

@gopherbot gopherbot added the Proposal label Jun 14, 2018

@roy2220

This comment has been minimized.

Copy link
Author

commented Jun 16, 2018

After I knew context.Context indeed, I realize this proposal is unnecessary.

@roy2220 roy2220 closed this Jun 16, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.