unc

module
v0.0.0-...-a1f6023 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2021 License: MIT

README

unc

Linter unc reports c-style nil checks.

Null checks with null on the left hand side (lhs) were popular in C to avoid the following bug:

if (some_var = NULL) ...

In Go such syntax is invalid, and hence c-style nil checks should not be used.

if someVar = nil ...
syntax error: cannot use assignment (someVar) = (nil) as value

Install

go get github.com/mneverov/unc

Run

unc ./...

go/analysis flags are available:

unc -h

To fix reported issues run:

unc -fix ./...

Example

func foo() {
	var err error

	if nil != err {
	}
}
unc ./...
foo.go:7:5: lhs nil  

Directories

Path Synopsis
cmd
unc
pkg
unc

Jump to

Keyboard shortcuts

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