waitabit icon indicating copy to clipboard operation
waitabit copied to clipboard

😴 A tiny library for handling system interrupts

Wait a bit

Tiny library for manage you application shutdown in graceful way by catching the OS signals.

⚠️ This repository is now archived. Please use os/signal.NotifyContext instead

Documentation

Installation

go get -u github.com/heartwilltell/waitabit

Usage

package main

import (
    "log"
    "os"

    "github.com/heartwilltell/waitabit"
)


func main() { 
	
    // call your application here ...
    
    wait := waitabit.NewWait(os.Interrupt)
    wait.WaitWithFunc(func() {
        log.Println("Bye")
    })
    
    // or ...
    
    waitabit.NewWait(os.Interrupt).WaitWithFunc(func() {
    	log.Println("Bye")
    })
    
}