https://github.com/mountolive/minisafe
Function wrapper for possibly panicking goroutines
https://github.com/mountolive/minisafe
go goroutines
Last synced: about 1 year ago
JSON representation
Function wrapper for possibly panicking goroutines
- Host: GitHub
- URL: https://github.com/mountolive/minisafe
- Owner: mountolive
- License: mit
- Created: 2020-07-26T21:57:26.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-10-14T10:18:45.000Z (over 5 years ago)
- Last Synced: 2023-03-05T20:04:34.820Z (over 3 years ago)
- Topics: go, goroutines
- Language: Go
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# MINISAFE
Safe net for panics inside goroutines.
This is a very raw port of [cookoo's](https://github.com/Masterminds/cookoo) safely.
# Installation
`go get github.com/mountolive/minisafe`
# Usage
```
package main
import (
"errors"
"fmt"
"github.com/mountolive/minisafe"
)
func main() {
// no params
minisafe.Go(routine)
// with params
msg := "I will be passed on"
minisafe.Go(func() {
routine(msg)
})
}
func routine(args...interface{}) {
fmt.Println("I'll run as a goroutine")
panicker()
}
func panicker() {
panic(errors.New("I will panick"))
}
```