Help us shape the future of Go! Take the 2026 Go Developer Survey

zsignal

package module
v0.0.0-...-56a6663 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2019 License: Apache-2.0 Imports: 4 Imported by: 5

README

zsignal

中断信号接收器

获得zsignal

go get -u github.com/zlyuancn/zsignal

导入zsignal

import "github.com/zlyuancn/zsignal"

实例

    RegisterOnShutdown(func() {
        fmt.Println("结束")
    })
    fmt.Println("请按下 ctrl + c")
    time.Sleep(10e9)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultSignal = new(Signal)

Functions

func RegisterOnShutdown

func RegisterOnShutdown(fn func())

注册一个函数, 在程序退出或收到退出信号时会调用它

func Shutdown

func Shutdown()

立即执行所有注册的函数

Types

type Signal

type Signal struct {
	// contains filtered or unexported fields
}

func (*Signal) Register

func (m *Signal) Register(fn func())

注册一个函数, 在程序退出或收到退出信号时会调用它

func (*Signal) Shutdown

func (m *Signal) Shutdown()

立即执行所有注册的函数

Jump to

Keyboard shortcuts

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