trace

package module
v0.0.0-...-f6c8830 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2018 License: MIT Imports: 0 Imported by: 5

README

=====
trace
=====

|image0|_ |image1|_ |image2|_

.. |image0| image:: https://godoc.org/github.com/eraclitux/trace?status.svg
.. _image0: https://godoc.org/github.com/eraclitux/trace

.. |image1| image:: https://travis-ci.org/eraclitux/trace.svg?branch=master
.. _image1: https://travis-ci.org/eraclitux/trace

.. |image2| image:: https://goreportcard.com/badge/github.com/eraclitux/trace
.. _image2: https://goreportcard.com/report/github.com/eraclitux/trace

Package ``trace`` is a simple tracing package. See `godoc <https://godoc.org/github.com/eraclitux/trace>`_ for usage examples.

Installation
============

To install with the ``trace-clean`` command::

        $ go get github.com/eraclitux/trace/...

Credits
=======

Original idea is by Dave Cheney http://dave.cheney.net.

Documentation

Overview

Package trace exposes simple tracing capabilities.

The idea is that during early stages of code development one wants a simple (and dirty :)) way to inspect values of vars that can be quickly disabled.

To enable trace functions to print, just build, run or test with “debug“ tag otherwise they will be noops:

go build -tags debug
go test -tags debug
go run -tags debug main.go

stderr is used to not perturb Examples() functions.

Once trace is no more needed, the provided command can be used to remove its presence in a code base, for example:

trace-clean -r .

will recursively remove import and function calls from all go files in the current directory and all its subdirs.

Credits

Original idea by Dave Cheney http://dave.cheney.net.

Example
package main

import (
	"fmt"

	"github.com/eraclitux/trace"
)

func main() {
	s := "my-value"
	fmt.Println("This is printed")
	// This will print to stderr only if '-tags debug' is used when building/running
	trace.Println("Value of s:", s)

}
Output:

This is printed

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrettyPrint

func PrettyPrint(name string, s interface{})

PrettyPrint prints types in a human readable format to stderr.

func Printf

func Printf(format string, a ...interface{})

Printf prints to stderr using supplied format if '-tags debug' is used when building/running, otherwise it is a no-op. stderr is used to not perturb example tests.

func Println

func Println(args ...interface{})

Println prints to stderr if '-tags debug' is used when building/running, noop otherwise. stderr is used to not perturb example tests.

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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