ghook

package
v0.0.0-...-3e416e1 Latest Latest
Warning

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

Go to latest
Published: May 19, 2024 License: MIT Imports: 7 Imported by: 2

README

Demo

hook package does prevent your program main function to exit when all your worker code in goroutine.

package hook

import (
	"github.com/snail007/gmc/process/hook"
)

func main() {
	//your business code here
	
	ghook.RegistShutdown(func() {
		//do something before program exit
	})
    //this will waiting for singal, prevent program main function to exit
	ghook.WaitShutdown()
}

Documentation

Overview

Package ghook package does prevent your program main function to exit when all your worker code in goroutine.

Example
//the code block should be last in your main function code

RegistShutdown(func() {
	//do something before program exit
})
WaitShutdown()
Output:

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	IsMock = false
)

Functions

func MockShutdown

func MockShutdown()

MockShutdown just for testing

func RegistShutdown

func RegistShutdown(fn func())

func WaitShutdown

func WaitShutdown()

Types

This section is empty.

Jump to

Keyboard shortcuts

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