d

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

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

Go to latest
Published: Dec 2, 2018 License: MIT Imports: 16 Imported by: 0

README

d

Build Status GoDoc Go Report Card

d is a better way to do print statement debugging.

Type d.D instead of fmt.Printf and your variables will be printed like this:

d output examples

Why is this better than fmt.Printf?

  • Faster to type
  • Pretty-printed vars and expressions
  • Easier to see inside structs
  • Pretty colors!

d is fork of https://github.com/y0ssar1an/q with some differences:

  • Do not include vendor into repository
  • Changed default behaviour - for me is more comfortable to log on stdout or have possibility to change file
  • Settings for removing colors

Basic Usage

import "github.com/marusama/d"
...
d.D(a, b, c)

// Alternatively, use the . import and you can omit the package name.
// d only exports the D function.
import . "github.com/marusama/d"
...
D(a, b, c)

For best results, dedicate a terminal to tailing $TMPDIR/d while you work.

Install

go get -u github.com/marusama/d

Editor Integration

Sublime Text
cp $GOPATH/src/github.com/marusama/d/dd.sublime-snippet Packages/User/dd.sublime-snippet
Atom

Navigate to your snippets.cson file by either opening ~/.atom/snippets.cson directly or by selecting the Atom > Open Your Snippets menu. You can then add this code snippet to the bottom and save the file:

'.source.go':
  'd log':
    'prefix': 'dd'
    'body': 'd.D($1)'
VS Code

In the VS Code menu go to Preferences and choose User Snippets. When the language dropdown menu appears select GO. Add the following snippet to the array of snippets.

"d.D": {
	"prefix": "dd",
	"body": [
		"d.D($1)"
	],
	"description": "Quick and dirty debugging output for tired Go programmers"
}
vim/Emacs

TBD Send me a PR, please :)

Haven't I seen this somewhere before?

Python programmers will recognize this as a Golang port of the q module by zestyping.

Ping does a great job of explaining q in his awesome lightning talk from PyCon 2013. Watch it! It's funny :)

ping's PyCon 2013 lightning talk

FAQ

Why d.D?

It's quick to type and unlikely to cause naming collisions.

Is d.D() safe for concurrent use?

Yes.

Documentation

Overview

package d provides quick and dirty debugging output for tired programmers.

d.D() is a fast way to pretty-print variables. It's easier than typing fmt.Printf("%#v", whatever). The output will be colorized and nicely formatted. The output goes to stdout or $OUT env var if defined.

d exports a single D() function. This is how you use it:

import "github.com/marusama/d"
...
d.D(a, b, c)

Index

Constants

View Source
const (
	OutEnv   = "OUT"
	ColorEnv = "COLOR"
)

Variables

This section is empty.

Functions

func D

func D(v ...interface{})

D pretty-prints the given arguments

Types

This section is empty.

Directories

Path Synopsis
Package pretty provides pretty-printing for Go values.
Package pretty provides pretty-printing for Go values.

Jump to

Keyboard shortcuts

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