heartwilltell / waitabit

😴 A tiny library for handling system interrupts

Home Page:https://pkg.go.dev/mod/github.com/heartwilltell/waitabit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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")
    })
    
}

About

😴 A tiny library for handling system interrupts

https://pkg.go.dev/mod/github.com/heartwilltell/waitabit

License:MIT License


Languages

Language:Go 100.0%