https://github.com/gobwas/deadline
Simple deadliner in Go.
https://github.com/gobwas/deadline
Last synced: 18 days ago
JSON representation
Simple deadliner in Go.
- Host: GitHub
- URL: https://github.com/gobwas/deadline
- Owner: gobwas
- Created: 2017-10-18T09:44:55.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-10-18T09:45:09.000Z (over 7 years ago)
- Last Synced: 2025-04-11T04:35:26.928Z (18 days ago)
- Language: Go
- Size: 1.95 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Deadline
[![GoDoc][godoc-image]][godoc-url]
> Tiny deadline helper for Go.
# Overview
This little package is intended to bring similar functionality as `net.Conn`'s
`SetDeadline()` methods family.# Usage
```go
package mainimport (
"github.com/gobwas/deadline"
)func main() {
d := deadline.Deadline{}
d.Set(time.Now().Add(time.Second))
err := d.Do(func() {
// This code will be running in a separate gorotuine.
})
if err != nil {
// Even if code still running, after a second we ge an error here and
// could handle it somehow.
}
}
```[godoc-image]: https://godoc.org/github.com/gobwas/deadline?status.svg
[godoc-url]: https://godoc.org/github.com/gobwas/deadline