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
Closed

proposal: time: add At function #25892

roy2220 opened this issue Jun 14, 2018 · 5 comments

Comments

@roy2220
Copy link

@roy2220 roy2220 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
Copy link
Contributor

@agnivade agnivade 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
Copy link
Member

@mvdan mvdan 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
Copy link
Member

@mvdan mvdan 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
Copy link
Author

@roy2220 roy2220 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
Copy link
Author

@roy2220 roy2220 commented Jun 16, 2018

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

@roy2220 roy2220 closed this Jun 16, 2018
@golang golang locked and limited conversation to collaborators Jun 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.