# README
Timeout - Give timeout power for function
Installation
To install the package, run:
go get github.com/go-zoox/timeout
Getting Started
func TestTimeout(t *testing.T) {
fn := func() error {
time.Sleep(100 * time.Millisecond)
fmt.Println("fn done")
return nil
}
err := Timeout(fn, 50*time.Millisecond)
if err == nil {
t.Errorf("expected timeout error, got nil")
}
err = Timeout(fn, 300*time.Millisecond)
if err != nil {
t.Errorf("expected nil, got %v", err)
}
}
License
GoZoox is released under the MIT License.
# Functions
Timeout call the function with timeout.
# Variables
Version is the version of this package.