crash

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2023 License: MIT Imports: 2 Imported by: 0

README

Manual

捕获运行时 panic

API

捕获 panic 并打印日志
func Recover(message string)

示例

package main

import (
	"github.com/o8x/jk/crash"
	"github.com/o8x/jk/signal"
)

func foo() {
	panic("panic in foo")
}

func main() {
	go func() {
		defer crash.Recover("recover by main")

		foo()
	}()

	signal.Wait()
}

运行它

> go run .
ERRO[0000] recover by main       recover="panic in foo" stack="goroutine .. [running]:....."

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Recover

func Recover(message string)

Types

This section is empty.

Jump to

Keyboard shortcuts

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