ryboe / q Goto Github PK
View Code? Open in Web Editor NEWQuick and dirty debugging output for tired Go programmers
License: MIT License
Quick and dirty debugging output for tired Go programmers
License: MIT License
A lot of stuff gets downloaded for the simple case of adding an import and a q.Q() .
All this can be removed by
go get ..linter
on contributors (removing the vendor dir)PR to follow
add Q to my project explodes my go.mod file with dependencies:
I suspect most of these are linting dependencies. Would there be any way to not have these normally pulled in?
require (
+ github.com/OpenPeeDeeP/depguard v0.0.0-20181229194401-1f388ab2d810 // indirect
+ github.com/StackExchange/wmi v0.0.0-20181212234831-e0a55b97c705 // indirect
github.com/benbjohnson/genesis v0.2.1
github.com/boltdb/bolt v1.3.1 // indirect
+ github.com/coreos/etcd v3.3.11+incompatible // indirect
+ github.com/fatih/color v1.7.0 // indirect
+ github.com/go-lintpack/lintpack v0.5.2 // indirect
+ github.com/go-ole/go-ole v1.2.2 // indirect
+ github.com/go-toolsmith/astcast v1.0.0 // indirect
+ github.com/go-toolsmith/astcopy v1.0.0 // indirect
+ github.com/go-toolsmith/astfmt v1.0.0 // indirect
+ github.com/go-toolsmith/astp v1.0.0 // indirect
+ github.com/go-toolsmith/pkgload v1.0.0 // indirect
+ github.com/go-toolsmith/typep v1.0.0 // indirect
+ github.com/gogo/protobuf v1.2.0 // indirect
+ github.com/golang/mock v1.2.0 // indirect
+ github.com/golangci/errcheck v0.0.0-20181223084120-ef45e06d44b6 // indirect
+ github.com/golangci/gocyclo v0.0.0-20180528144436-0a533e8fa43d // indirect
+ github.com/golangci/gofmt v0.0.0-20181222123516-0b8337e80d98 // indirect
+ github.com/golangci/golangci-lint v1.12.5 // indirect
+ github.com/golangci/lint-1 v0.0.0-20181222135242-d2cdd8c08219 // indirect
+ github.com/golangci/revgrep v0.0.0-20180812185044-276a5c0a1039 // indirect
+ github.com/golangci/tools v0.0.0-20190108095906-d95fd85c147a // indirect
+ github.com/golangci/unparam v0.0.0-20180902115109-7ad9dbcccc16 // indirect
github.com/gorilla/websocket v1.4.0
+ github.com/kr/pty v1.1.3 // indirect
+ github.com/mattn/go-isatty v0.0.4 // indirect
+ github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d // indirect
+ github.com/onsi/ginkgo v1.7.0 // indirect
+ github.com/onsi/gomega v1.4.3 // indirect
+ github.com/pkg/errors v0.8.1 // indirect
github.com/pkg/term v0.0.0-20181116001808-27bbf2edb814
+ github.com/shirou/gopsutil v2.18.12+incompatible // indirect
+ github.com/shurcooL/go v0.0.0-20181215222900-0143a8f55f04 // indirect
+ github.com/sirupsen/logrus v1.3.0 // indirect
+ github.com/spf13/afero v1.2.0 // indirect
+ github.com/spf13/cobra v0.0.3 // indirect
+ github.com/spf13/viper v1.3.1 // indirect
+ github.com/stretchr/testify v1.3.0 // indirect
github.com/timshannon/bolthold v0.0.0-20180829183128-83840edea944
+ github.com/ugorji/go/codec v0.0.0-20181209151446-772ced7fd4c2 // indirect
+ github.com/y0ssar1an/q v1.0.6 // indirect
go.etcd.io/bbolt v1.3.0 // indirect
- golang.org/x/sys v0.0.0-20181206074257-70b957f3b65e // indirect
+ golang.org/x/crypto v0.0.0-20190103213133-ff983b9c42bc // indirect
+ golang.org/x/image v0.0.0-20181116024801-cd38e8056d9b
+ golang.org/x/net v0.0.0-20190110200230-915654e7eabc // indirect
+ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 // indirect
+ golang.org/x/sys v0.0.0-20190109145017-48ac38b7c8cb // indirect
+ golang.org/x/tools v0.0.0-20190111214448-fc1d57b08d7b // indirect
+ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
periph.io/x/periph v3.4.0+incompatible
+ sourcegraph.com/sourcegraph/go-diff v0.5.0 // indirect
+ sourcegraph.com/sqs/pbtypes v1.0.0 // indirect
)
Whilst I love the name y0ssar1an, catch-22 is one of my all time favourite books, I need to look up the spelling everytime I use the library. This is kinda counter to the idea behind q.
Hence the suggestion to more the library to something more easily remember.
I have registered github.com/golangq, cloned q & added y0ssar1n as an owner.
thanks ~
Currently, q.log
can grow forever. It might be interesting if qq
could rotate the log. Maybe we could add a q.MaxFileSize
setting or something.
This even might be an issue on Linux, if the temp dir contents get written to RAM instead of disk.
The issue came from the line:
if a.Obj.Kind == ast.Var || a.Obj.Kind == ast.Con {
I did an output of "%#v %T" right before that and got:
&ast.Ident{NamePos:4893, Name:"tmpTest", Obj:(*ast.Object)(nil)} *ast.Ident
The object in question is a global variable or constant being printed from a test file.
Runnable example:
package main
import "github.com/y0ssar1an/q"
var panicInTests string
func main(){
q.Q(panicInTests) // This is OK
}
package main
import (
"testing"
"github.com/y0ssar1an/q"
)
func TestPanicQ(t *testing.T) {
q.Q(panicInTests) // This will panic
}
Full panic here:
go test
&ast.Ident{NamePos:102, Name:"panicInTests", Obj:(*ast.Object)(nil)} *ast.Ident
--- FAIL: TestPanicQ (0.00s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x113186f]
goroutine 6 [running]:
testing.tRunner.func1(0xc4200709c0)
/usr/local/go/src/testing/testing.go:622 +0x29d
panic(0x115a360, 0x1239920)
/usr/local/go/src/runtime/panic.go:489 +0x2cf
github.com/y0ssar1an/q.argName(0x122ada0, 0xc42000b020, 0x1224c26, 0x44)
/Users/johnschnake/go/src/github.com/y0ssar1an/q/helpers.go:30 +0x10f
github.com/y0ssar1an/q.argNames.func1(0x1229da0, 0xc420013380, 0x11102c8)
/Users/johnschnake/go/src/github.com/y0ssar1an/q/helpers.go:79 +0x16e
go/ast.inspector.Visit(0xc42000b0e0, 0x1229da0, 0xc420013380, 0x110220a, 0x0)
/usr/local/go/src/go/ast/walk.go:373 +0x3a
go/ast.Walk(0x12297a0, 0xc42000b0e0, 0x1229da0, 0xc420013380)
/usr/local/go/src/go/ast/walk.go:52 +0x66
go/ast.Walk(0x12297a0, 0xc42000b0e0, 0x12f6168, 0xc42000f120)
/usr/local/go/src/go/ast/walk.go:196 +0x1eb7
go/ast.walkStmtList(0x12297a0, 0xc42000b0e0, 0xc42000f140, 0x1, 0x1)
/usr/local/go/src/go/ast/walk.go:32 +0x89
go/ast.Walk(0x12297a0, 0xc42000b0e0, 0x1229d60, 0xc420018b10)
/usr/local/go/src/go/ast/walk.go:224 +0x1f16
go/ast.Walk(0x12297a0, 0xc42000b0e0, 0x12f60d8, 0xc420018b40)
/usr/local/go/src/go/ast/walk.go:344 +0xf63
go/ast.walkDeclList(0x12297a0, 0xc42000b0e0, 0xc42000b080, 0x2, 0x2)
/usr/local/go/src/go/ast/walk.go:38 +0x89
go/ast.Walk(0x12297a0, 0xc42000b0e0, 0x1229ee0, 0xc42008ea00)
/usr/local/go/src/go/ast/walk.go:353 +0x2bb1
go/ast.Inspect(0x1229ee0, 0xc42008ea00, 0xc42000b0e0)
/usr/local/go/src/go/ast/walk.go:385 +0x4b
github.com/y0ssar1an/q.argNames(0x1224c26, 0x44, 0xa, 0x3, 0x3, 0x4c, 0x0, 0x0)
/Users/johnschnake/go/src/github.com/y0ssar1an/q/helpers.go:82 +0x29d
github.com/y0ssar1an/q.Q(0xc42002c788, 0x1, 0x1)
/Users/johnschnake/go/src/github.com/y0ssar1an/q/q.go:175 +0x17c
github.com/johnSchnake/qPanic.TestPanicQ(0xc4200709c0)
/Users/johnschnake/go/src/github.com/johnSchnake/qPanic/main_test.go:10 +0x7f
testing.tRunner(0xc4200709c0, 0x118f018)
/usr/local/go/src/testing/testing.go:657 +0x96
created by testing.(*T).Run
/usr/local/go/src/testing/testing.go:697 +0x2ca
exit status 2
FAIL github.com/johnSchnake/qPanic 0.011s
GOPATH
doesn't need to exist within environ in latest Golang. $HOME/go
is inferred.
PR momentarily cleaning this and a few other shell nits.
q is one of my most used tools, so thanks for writing it. I know the project is considered feature complete, but I did want to make you aware of one thing I added that might be one interest, primarily because of its simplicity.
A common need I have is to observe the state inside some common, high-traffic function, which is called by everything, but only when I'm in some code of interest that using that function. Just dropping q in generates a ton of output. To help with this, I added On/Off functions to provide a master switch from the top level. They're so simple I thought I'd make you aware, and can PR if you are interested (and no prob if not).
Thanks again.
Should i delete q
on production environment?
panic: runtime error: index out of range
goroutine 1 [running]:
github.com/y0ssar1an/q.prependArgName(0xc420403480, 0x2, 0x2, 0xc42043d0f0, 0x1, 0x1, 0x0, 0x0, 0x2)
/Users/ryan/go/src/github.com/y0ssar1an/q/helpers.go:156 +0x347
github.com/y0ssar1an/q.Q(0xc4201206c0, 0x1, 0x1)
/Users/ryan/go/src/github.com/y0ssar1an/q/q.go:182 +0x20a
github.com/apcera/apcera-setup/vendor/github.com/apcera/libretto/virtualmachine/azure/arm.(*VM).deploy(0xc420082340, 0xc4204b4350, 0x5)
/Users/ryan/go/src/github.com/apcera/apcera-setup/vendor/github.com/apcera/libretto/virtualmachine/azure/arm/util.go:170 +0x30a
github.com/apcera/apcera-setup/vendor/github.com/apcera/libretto/virtualmachine/azure/arm.(*VM).Provision(0xc420082340, 0xc420000180, 0x300000002)
/Users/ryan/go/src/github.com/apcera/apcera-setup/vendor/github.com/apcera/libretto/virtualmachine/azure/arm/vm.go:135 +0xc1
github.com/apcera/apcera-setup/commands/create.createVM(0xc42047e1e0, 0x1f, 0xc420120ca0)
/Users/ryan/go/src/github.com/apcera/apcera-setup/commands/create/create.go:368 +0x54
github.com/apcera/apcera-setup/commands/create.createBaseVMs(0xc42028e5a0, 0x3, 0x4, 0x1e49360, 0xc420470630, 0x1e49360, 0xc420470640)
/Users/ryan/go/src/github.com/apcera/apcera-setup/commands/create/create.go:432 +0x4a3
github.com/apcera/apcera-setup/commands/create.createVMs(0xc42028e5a0, 0x3, 0x4, 0xc4202c0240, 0x0, 0x0, 0x0)
/Users/ryan/go/src/github.com/apcera/apcera-setup/commands/create/create.go:460 +0xad
github.com/apcera/apcera-setup/commands/create.Run(0xc4202be480, 0x3c6a8f8, 0x0, 0x0, 0xc4202c0240, 0x0, 0x0)
/Users/ryan/go/src/github.com/apcera/apcera-setup/commands/create/create.go:242 +0x675
github.com/apcera/apcera-setup/commands.ConfiguredCommand.func1(0xc4202be480, 0x3c6a8f8, 0x0, 0x0)
/Users/ryan/go/src/github.com/apcera/apcera-setup/commands/commands.go:111 +0x1b9
github.com/apcera/apcera-setup/commands.UpdateCheck.func1(0xc4202be480, 0x3c6a8f8, 0x0, 0x0)
/Users/ryan/go/src/github.com/apcera/apcera-setup/commands/commands.go:169 +0xe5
github.com/apcera/apcera-setup/vendor/github.com/spf13/cobra.(*Command).execute(0xc4202be480, 0x3c6a8f8, 0x0, 0x0, 0xc4202be480, 0x3c6a8f8)
/Users/ryan/go/src/github.com/apcera/apcera-setup/vendor/github.com/spf13/cobra/command.go:653 +0x2a2
github.com/apcera/apcera-setup/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x3c41c20, 0x2210ef1, 0xb, 0xc420121f60)
/Users/ryan/go/src/github.com/apcera/apcera-setup/vendor/github.com/spf13/cobra/command.go:728 +0x2fe
main.main()
/Users/ryan/go/src/github.com/apcera/apcera-setup/apcera-setup.go:32 +0x38
I see this:
Render p.NodeType=hugolib.NodeType(3)
NodeType
is an int
, but implements the Stringer
interface, so I would expect the String()
output to be in there somewhere.
package main
import (
. "github.com/y0ssar1an/q"
)
func main() {
test()
Q("Third")
}
func test() {
defer Q("Second")
Q("First")
}
Produces output
[18:49:47 qtest/main.go:14 main.test]
0.000s First
0.000s
[18:49:47 qtest/main.go:9 main.main]
0.000s Third
Expected
[18:49:47 qtest/main.go:14 main.test]
0.000s First
0.000s Second
[18:49:47 qtest/main.go:9 main.main]
0.000s Third
q.Q panic when have to print an empty *time.Time
Version: v1.0.17
Steps to reproduce:
var emptyDate *time.Time
q.Q(emptyDate)
Current result:
emptyDate=%!v(PANIC=Format method: value method time.Time.GoString called using nil *Time pointer)
Expected result
emptyDate=(*time.Time)(nil)
http://apps.samsung.com/them? e/ProductDetail.as?- [ ] appId=com.jnl.Black550-k z [ ] .w __allpa _ perbpack
When tryinq to use q
in a project which uses go mod, any command run exits with an error. I am a little suspicious that the issue is really just a bad error message, but I don't quite see how it is getting triggered. Hopefully it make sense to you.
Here is a very simple example that shows the issue.
Create a dir with the following contents in main.go:
// Package main provides an example of q/mod failure
package main
import "github.com/y0ssar1an/q"
func main() {
i := 1
t := []int{1, 2, 3}
q.Q(i, t)
}
run go mod init github.com/reedobrien/w
run go build
and get the error:
go: finding github.com/golangci/tools v0.0.0-20180902102414-2cefd77fef9b
go: github.com/golangci/[email protected]: unknown revision 2cefd77fef9b
I don't see golangci or tools in the q repo... so I suspect someone doing something clever vending dependencies, a bug in go mod, or both. Also I've been away from go for a bit and haven't used modules in anger before my current project. So I am a bit lost with them. Hopefully this rings a bell in your head.
this is really useful for CLi apps also.
so when i do q.Q(variable), it also prints out to the STDout
I coudl tail the temp log, but then i loose control of intermixing.
for example i want everything to go to tmp log but only some things to go to stdout.
I sort of started to use this for nice formatting
Using go1.13.7 for building my project (that uses github.com/y0ssar1an/q as a dependency) I got the error:
github.com/y0ssar1an/[email protected] requires
github.com/golangci/[email protected] requires
github.com/golangci/[email protected]: invalid version: unknown revision 2cefd77fef9b
I've cloned the repository, made local changes in go.mod (just set up go1.13)
index 86f936a..092e9a3 100644
--- a/go.mod
+++ b/go.mod
@@ -1,5 +1,5 @@
module github.com/y0ssar1an/q
-go 1.12
+go 1.13
require github.com/kr/pretty v0.2.0
(END)
used the 'replace' in my project's go.mod (from github.com/y0ssar1an/q to local copy) - and that helped.
It seems it could be better to use go1.13 in master to avoid problems like this one.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.