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. Expand ▾ Collapse ▴ Documentation ¶ Index ¶ Variables func Timeout(fn func() error, timeout time.Duration, message ...string) (err error) Constants ¶ This section is empty. Variables ¶ View Source var Version = "1.0.3" Version is the version of this package. Functions ¶ func Timeout ¶ func Timeout(fn func() error, timeout time.Duration, message ...string) (err error) Timeout call the function with timeout Types ¶ This section is empty. Source Files ¶ View all Source files timeout.go version.go Click to show internal directories. Click to hide internal directories.