Categorygithub.com/go-zoox/timeout
modulepackage
1.0.3
Repository: https://github.com/go-zoox/timeout.git
Documentation: pkg.go.dev

# README

Timeout - Give timeout power for function

PkgGoDev Build Status Go Report Card Coverage Status GitHub issues Release

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.