fnutils

package
v1.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package fnutils provides a set of utilities for working with functions in Go.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteAfter

func ExecuteAfter(fn func(), timeout time.Duration) (err error)

ExecuteAfter executes the given function after the specified timeout duration. It returns any error encountered during the execution. It waits for the specified duration and then calls the provided function.

Example:

err := ExecuteAfter(func() {
    fmt.Println("Hello, World!")
}, time.Second)

@param fn The function to be executed.

@param timeout The duration to wait before executing the function.

@returns An error encountered during execution, if any.

func ExecuteAfterMin

func ExecuteAfterMin(fn func(), timeout int) (err error)

ExecuteAfterMin executes the given function after the specified timeout duration, expressed in minutes. It returns any error encountered during the execution.

It converts the timeout value from minutes to a duration in seconds and then calls the ExecuteAfter function, passing the converted duration and the provided function.

Example:

err := ExecuteAfterMin(func() {
    fmt.Println("Hello, World!")
}, 5)

@param fn The function to be executed.

@param timeout The timeout duration in minutes.

@returns An error encountered during execution, if any.

func ExecuteAfterMs

func ExecuteAfterMs(fn func(), timeout int64) (err error)

ExecuteAfterMs executes the given function after the specified timeout duration, expressed in milliseconds. It returns any error encountered during the execution.

It converts the timeout value from milliseconds to a duration in seconds and then calls the ExecuteAfter function, passing the converted duration and the provided function.

Example:

err := ExecuteAfterMs(func() {
    fmt.Println("Hello, World!")
}, 1000)

@param fn The function to be executed.

@param timeout The timeout duration in milliseconds.

@returns An error encountered during execution, if any.

func ExecuteAfterSecs

func ExecuteAfterSecs(fn func(), timeout int) (err error)

ExecuteAfterSecs executes the given function after the specified timeout duration, expressed in seconds. It returns any error encountered during the execution.

It converts the timeout value from seconds to a duration in seconds and then calls the ExecuteAfter function, passing the converted duration and the provided function.

Example:

err := ExecuteAfterSecs(func() {
    fmt.Println("Hello, World!")
}, 10)

@param fn The function to be executed.

@param timeout The timeout duration in seconds.

@returns An error encountered during execution, if any.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL