Git Product home page Git Product logo

q's Introduction

q

Build Status GoDoc Go Report Card

q is a better way to do print statement debugging.

Type q.Q instead of fmt.Printf and your variables will be printed like this:

q output examples

Why is this better than fmt.Printf?

  • Faster to type
  • Pretty-printed vars and expressions
  • Easier to see inside structs
  • Doesn't go to noisy-ass stdout. It goes to $TMPDIR/q.
  • Pretty colors!

Basic Usage

import "github.com/y0ssar1an/q"
...
q.Q(a, b, c)

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

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

Install

go get -u github.com/y0ssar1an/q

Put these aliases in your shell config. Typing qq will then start tailing $TMPDIR/q.

alias qq=". $GOPATH/src/github.com/y0ssar1an/q/q.sh"
alias rmqq="rm $TMPDIR/q"

Editor Integration

Sublime Text

cp $GOPATH/src/github.com/y0ssar1an/q/qq.sublime-snippet Packages/User/qq.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':
  'q log':
    'prefix': 'qq'
    'body': 'q.Q($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.

"q.Q ": {
	"prefix": "qq",
	"body": [
		"q.Q($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 q.Q?

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

Is q.Q() safe for concurrent use?

Yes

q's People

Contributors

ryboe avatar variadico avatar trizko avatar

Watchers

James Cloos avatar tommyjarvis avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.