Skip to content

Commit

Permalink
docs: autoupdate
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinJWendt committed Oct 22, 2023
1 parent f4dc7c0 commit 0eabe5e
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,15 @@ package main

import (
"atomicgo.dev/timeout"
"errors"
"fmt"
"time"
)

func main() {
res, err := timeout.Execute(time.Second*2, func() (string, error) {
time.Sleep(time.Second * 1)
return "", fmt.Errorf("some error")
return "", errors.New("some error") // nolint: goerr113
})

fmt.Println(res, err)
Expand All @@ -172,12 +173,21 @@ some error

## Index

- [Variables](<#variables>)
- [func Execute\[T any\]\(duration time.Duration, fn Function\[T\]\) \(T, error\)](<#Execute>)
- [type Function](<#Function>)


## Variables

<a name="ErrTimeoutReached"></a>ErrTimeoutReached is returned when the timeout is reached.

```go
var ErrTimeoutReached = errors.New("timeout reached")
```

<a name="Execute"></a>
## func [Execute](<https://github.com/atomicgo/timeout/blob/main/timeout.go#L13>)
## func [Execute](<https://github.com/atomicgo/timeout/blob/main/timeout.go#L17>)

```go
func Execute[T any](duration time.Duration, fn Function[T]) (T, error)
Expand All @@ -186,9 +196,9 @@ func Execute[T any](duration time.Duration, fn Function[T]) (T, error)
Execute executes a function and returns the result or an error if the timeout is reached. If the timeout is reached, the Function will be interrupted. If the Function returns an error, the error will be returned.

<a name="Function"></a>
## type [Function](<https://github.com/atomicgo/timeout/blob/main/timeout.go#L8>)

## type [Function](<https://github.com/atomicgo/timeout/blob/main/timeout.go#L9>)

Function is a function that returns a generic value and an error.

```go
type Function[T any] func() (T, error)
Expand Down

0 comments on commit 0eabe5e

Please sign in to comment.