debug

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2025 License: MPL-2.0 Imports: 8 Imported by: 10

README

go-debug

Go Reference

go-debug is a Sidero-specific library for including debugging facilities for developers in our products when they are compiled with sidero.debug build tag. They are not included by default. Also provides utils for detecting if the code was compiled with race build tag.

Documentation

Overview

Package debug is a Sidero-specific library for including debugging facilities for developers in our products when they are compiled with sidero.debug build tag. They are not included by default. Also provides utils for detecting if the code was compiled with race build tag.

Index

Constants

View Source
const Enabled = false

Enabled is false when compiled without sidero.debug build tag.

Profiling is disabled to safe resources as a side-effect of importing this package.

View Source
const RaceEnabled = false

RaceEnabled is false when compiled without race build tag.

Variables

This section is empty.

Functions

func ListenAndServe

func ListenAndServe(ctx context.Context, addr string, log LogFunc) error

ListenAndServe runs debug server on given address.

If debugging is enabled (debug.Enabled is true), the function blocks until fatal error in encountered (it is returned) or ctx is canceled (in that case, nil is returned).

If debugging is disabled (debug.Enabled is false), the function immediately returns nil.

Both cases can be handled with the following code:

if err := debug.ListenAndServe(ctx, addr, log); err != nil {
    log.Fatal(err)
}

Types

type LogFunc

type LogFunc func(msg string)

LogFunc is a simplest logging function.

Jump to

Keyboard shortcuts

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