ProductPromotion
Logo

Go.Lang

made by https://0x3d.site

GitHub - sinhashubham95/bleep: OS Signal Handlers in Go
OS Signal Handlers in Go. Contribute to sinhashubham95/bleep development by creating an account on GitHub.
Visit Site

GitHub - sinhashubham95/bleep: OS Signal Handlers in Go

GitHub - sinhashubham95/bleep: OS Signal Handlers in Go

Bleep

GoDoc Release Report Coverage Status Mentioned in Awesome Go

Bleep is used to peform actions on OS signals. It is highly extensible and goroutine safe. It is possible to add any number of actions and all of them are guaranteed to be performed simultaneously on the OS signals that Bleep will be listening for.

Installation

go get github.com/sinhashubham95/bleep

How to Use

The Bleep package allows you to create a new instance of the handler and also has a default handler in place that can be used directly.

Creating separate Bleep instances can be useful, when you want to perform different set of actions for different set of OS signals.

Create a New OS Signal Handler

This is used to create a new handler for performing actions on OS Signals.

import (
  "os"
  "github.com/sinhashubham95/bleep"
)

func New() {
  handler := bleep.New()
  // now this handler can be used to add or remove actions and listen to the OS signals
}

Add an Action

This is used to add an action to be executed on the OS signal listening for.

import (
  "os"
  "github.com/sinhashubham95/bleep"
)

fun Add() {
  key := bleep.Add(func (s os.Signal) {
    // do something
  })
  // this key is the unique identifier for your added action
}

Remove an Action

This is used to remove an action added to Bleep.

import (
  "github.com/sinhashubham95/bleep"
)

func Remove() {
  action := bleep.Remove("some-key")  // this key should be the same as the one returned during adding the action
  // the returned action is the one that was added using this key
}

Listen

This is used to listen for the OS signals. Note that this will wait for the signal in the go routine in which this is called.

import (
  "syscall"
  "github.com/sinhashubham95/bleep"
)

func Listen() {
  bleep.Listen(syscall.SIGINT, syscall.SIGTERM)
}

Articles
to learn more about the golang concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

Queries
or most google FAQ's about GoLang.

mail [email protected] to add more queries here ๐Ÿ”.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory