safe

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2022 License: MIT Imports: 2 Imported by: 7

README

Safe

Safe function execution without panic

PkgGoDev Build Status Go Report Card Coverage Status GitHub issues Release

Installation

To install the package, run:

go get github.com/go-zoox/safe

Getting Started

import (
  "testing"
  "github.com/go-zoox/safe"
)

func main(t *testing.T) {
	loadConfig := func() {
		panic("load config panic")
	}

	if err := safe.Do(loadConfig); err != nil {
		log.Error(err)
	}
}

Inspired By

License

GoZoox is released under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version = "1.0.1"

Version is the current version of the package.

Functions

func Do

func Do(fn func() error) (err error)

Do solves panic automatically, converts it to an error and returns it.

func Func

func Func(fn func() error) func() error

Func returns the method to be executed safely.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL