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:
- 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!
import "github.com/y0ssar1an/q"
...
q.Q(a, b, c)
// Alternatively, use the . import and you can omit the package name.
import . "github.com/y0ssar1an/q"
...
Q(a, b, c)
For best results, dedicate a terminal to tailing $TMPDIR/q
while you work.
go get -u github.com/y0ssar1an/q
Put these functions in your shell config. Typing qq
or rmqq
will then start
tailing $TMPDIR/q
.
qq() {
clear
local gpath="${GOPATH:-$HOME/go}"
"${gpath%%:*}/src/github.com/y0ssar1an/q/q.sh" "$@"
}
rmqq() {
if [[ -f "$TMPDIR/q" ]]; then
rm "$TMPDIR/q"
fi
qq
}
Preferences > User Snippets > Go
"qq": {
"prefix": "qq",
"body": "q.Q($1) // DEBUG",
"description": "Pretty-print to $TMPDIR/q"
}
Tools > Developer > New Snippet
<snippet>
<content><![CDATA[
q.Q($1) // DEBUG
]]></content>
<tabTrigger>qq</tabTrigger>
<scope>source.go</scope>
</snippet>
Atom > Open Your Snippets
'.source.go':
'qq':
'prefix': 'qq'
'body': 'q.Q($1) // DEBUG'
TBD Send me a PR, please :)
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 :)
It's quick to type and unlikely to cause naming collisions.
Yes.