first commit

This commit is contained in:
2020-01-15 13:35:30 +01:00
commit c9cd268366
15 changed files with 1884 additions and 0 deletions

21
closehandle.go Normal file
View File

@@ -0,0 +1,21 @@
package main
import (
"fmt"
"os"
"os/signal"
"syscall"
)
// SetupCloseHandler creates a 'listener' on a new goroutine which will notify the
// program if it receives an interrupt from the OS. We then handle this by calling
// our clean up procedure and exiting the program.
func SetupCloseHandler() {
c := make(chan os.Signal, 2)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
go func() {
<-c
fmt.Println("\r- Ctrl+C pressed in Terminal")
os.Exit(0)
}()
}