Skip to content

Waits and gracefully stops golang program if CTRL+C called

License

Notifications You must be signed in to change notification settings

MasterDimmy/go-ctrlc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

go-ctrlc

Waits and gracefully stops golang program if CTRL+C called

Provides usefull CTRL+C interface, used to intercept ctrl+c signal to stop program outside or by internal command

Usage:

func main() {
	var ctrlc CtrlC
	defer ctrlc.DeferThisToWaitCtrlC(true)

	....

	go some_your_logic()
	....

	ctrl.InterceptKill(true, func() {
		fmt.Println("software was stopped via Ctrl+C")
	})
}

About

Waits and gracefully stops golang program if CTRL+C called

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages