godebug

package module
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2024 License: MIT Imports: 9 Imported by: 198

README

godebug

license

Small library of tools for debugging Go (golang) programs.

The most useful of these is LF(). It returns a line number and file name. The parameter is an optional number. 1 indicates that you want it for the current call. 2 would be the parent of the current call.

Example:


	package main

	import (
		"fmt"

		"github.com/pschlump/godebug"
	)

	func main() {
		fmt.Printf("I am at: %s\n", godebug.LF())
	}

LF() takes an optional parameter, 1 indicates the current function, 2 is the parent, 3 the grandparent.

I will add complete documentation tomorrow.

ChkEnv

Return true if the passed environment variable can be parsed to be a true value. Values are cached so that the os.Getenv is only called once for each variable.

There is a test in ./test/test.sh to test this (or use the Makefile).

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ColorTab map[string]string

Functions

func ChkEnv

func ChkEnv(envVar string) bool

func Db2Printf

func Db2Printf(flag bool, format string, a ...interface{}) (n int, err error)

Printf with a true false flag.

func DbFpf added in v1.0.1

func DbFpf(db bool, w io.Writer, format string, a ...interface{}) (n int, err error)

func DbPf

func DbPf(db bool, format string, a ...interface{}) (n int, err error)

func DbPfb

func DbPfb(db bool, format string, a ...interface{}) (n int, err error)

func DbPfe

func DbPfe(envVar string, format string, a ...interface{}) (n int, err error)

func FILE

func FILE(d ...int) string

FILE Returns the current file name.

func FUNCNAME

func FUNCNAME(d ...int) string

FUNCNAME returns the current function name as a string.

func Fprintf

func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error)

func IAmAt

func IAmAt(s ...string)

IAmAt print out the current Function,File,Line No and an optional set of strings.

func IAmAt2

func IAmAt2(s ...string)

IAmAt2 prints out the current Function,File,Line No and an optional set of strings - do this for 2 levels deep.

func InArrayInt

func InArrayInt(s int, arr []int) int

Return 0..n if 'n' is in the array arr, else -1.

func InArrayString

func InArrayString(s string, arr []string) int

Return 0..n if 's' is in the array arr, else -1.

func LF

func LF(d ...int) string

LF Returns the File name and Line no as a string.

func LF2

func LF2(d ...int) (line int, file string)

LF2 returns the line/file for the parent.

func LFj

func LFj(d ...int) string

LFj returns the File name and Line no as a string. - for JSON as string

func LINE

func LINE(d ...int) string

LINE Return the current line number as a string. Default parameter is 1, must be an integer That reflects the depth in the call stack. A value of 0 would be the LINE() function itself. If you supply more than one parameter, 2..n are ignored.

func LINEnf

func LINEnf(d ...int) (int, string)

LINEnf Returns line number, 0 if error

func ParseBool

func ParseBool(s string) (b bool)

func Printf

func Printf(format string, a ...interface{}) (n int, err error)

func ProcessFormat

func ProcessFormat(format string) string

func SVar

func SVar(v interface{}) string

SVar return the JSON encoded version of the data.

func SVarI

func SVarI(v interface{}) string

SVarI return the JSON encoded version of the data with tab indentation.

func SetFlag

func SetFlag(name, sValue string)

func TrIAmAt

func TrIAmAt(s ...string)

Hm...

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