flagtrace

package module
v0.0.0-...-5d34715 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package flagtrace provides easy tracing of the program (using runtime/trace) by enabling a command-line flag.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(flags *flag.FlagSet, flagName string, usage string) (stopTracing func())

Register registers a flag to enable tracing with runtime/trace.

The returned func must be run defered to stop the tracing and close the file.

When tracing is enabled, a handler for SIGINT (^C) is also registered to properly stop tracing and close the file.

Example
package main

import (
	"flag"
	"fmt"

	"github.com/dolmen-go/flagx/flagtrace"
)

func main() {
	stopTracing := flagtrace.Register(flag.CommandLine, "debug.trace", "trace `file` (for go tool trace)")
	defer stopTracing()

	flag.Parse()

	fmt.Println("hello, world!")

}
Output:

hello, world!

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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