Home

Awesome

dogsled Build Status

dogsled is a Go static analysis tool to find assignments/declarations with too many blank identifiers (e.g. x, _, _, _ := f()). Its name was inspired from this reddit post.

Installation

go get -u github.com/alexkohler/dogsled/cmd/dogsled

Usage

Similar to other Go static analysis tools (such as golint, go vet), dogsled can be invoked with one or more filenames, directories, or packages named by its import path. dogsled also supports the ... wildcard. By default, it will search for assignment with more than two blank identifiers.

dogsled [flags] files/directories/packages

Flags

Example

Some examples from the Go standard library

$ dogsled go/src/...
go/src/crypto/elliptic/elliptic_test.go:553: declaration has 3 blank identifiers: priv, _, _, _ := GenerateKey(p256,go/src/image/names.go:46: declaration has 3 blank identifiers: _, _, _, a := c.C.RGBA()
go/src/image/color/color.go:232: declaration has 3 blank identifiers: _, _, _, a := c.RGBA()
go/src/image/color/color.go:240: declaration has 3 blank identifiers: _, _, _, a := c.RGBA()
go/src/internal/cpu/cpu_x86.go:67: declaration has 3 blank identifiers: maxID, _, _, _ := cpuid(0, 0)
go/src/internal/cpu/cpu_x86.go:100: declaration has 3 blank identifiers: _, ebx7, _, _ := cpuid(7, 0)
go/src/math/big/natconv_test.go:286: declaration has 3 blank identifiers: x, _, _, _ = x.scan(strings.NewReader(pi),go/src/reflect/value.go:172: declaration has 3 blank identifiers: pc, _, _, _ := runtime.Caller(2)
go/src/reflect/makefunc.go:62: declaration has 4 blank identifiers: _, _, _, stack, _ := funcLayout(t, nil)
go/src/reflect/makefunc.go:113: declaration has 4 blank identifiers: _, _, _, stack, _ := funcLayout(funcType, nil)
go/src/runtime/softfloat64.go:309: declaration has 4 blank identifiers: _, _, _, _ = fi, fn, gi, gn
go/src/runtime/symtab_test.go:54: declaration has 3 blank identifiers: _, _, line, _ := runtime.Caller(1)
go/src/syscall/syscall_unix_test.go:182: declaration has 3 blank identifiers: _, oobn, _, _, err := uc.ReadMsgUnixgo/src/time/time.go:498: declaration has 3 blank identifiers: year, _, _, _ := t.date(false)
go/src/time/time.go:504: declaration has 3 blank identifiers: _, month, _, _ := t.date(true)
go/src/time/time.go:510: declaration has 3 blank identifiers: _, _, day, _ := t.date(true)
go/src/time/time.go:624: declaration has 3 blank identifiers: _, _, _, yday := t.date(false)

Contributing

Please open an issue and/or a PR for any features/bugs.

Other static analysis tools

If you've enjoyed dogsled, take a look at my other static anaylsis tools!