Movatterモバイル変換


[0]ホーム

URL:


exithook

packagestandard library
go1.25.2Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2025 License:BSD-3-ClauseImports:2Imported by:0

Details

Repository

cs.opensource.google/go/go

Links

Documentation

Overview

Package exithook provides limited support for on-exit cleanup.

CAREFUL! The expectation is that Add should only be calledfrom a safe context (e.g. not an error/panic path or signalhandler, preemption enabled, allocation allowed, write barriersallowed, etc), and that the exit function F will be invoked undersimilar circumstances. That is the say, we are expecting that Fuses normal / high-level Go code as opposed to one of the morerestricted dialects used for the trickier parts of the runtime.

Index

Constants

This section is empty.

Variables

View Source
var (// runtime sets these for usGosched func()Goid    func()uint64Throw   func(string))

Functions

funcAdd

func Add(hHook)

Add adds a new exit hook.

funcRun

func Run(codeint)

Run runs the exit hooks.

If an exit hook panics, Run will throw with the panic on the stack.If an exit hook invokes exit in the same goroutine, the goroutine will throw.If an exit hook invokes exit in another goroutine, that exit will block.

Types

typeHook

type Hook struct {F            func()// func to runRunOnFailurebool// whether to run on non-zero exit code}

A Hook is a function to be run at program termination(when someone invokes os.Exit, or when main.main returns).Hooks are run in reverse order of registration:the first hook added is the last one run.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp