niller

package module
v0.0.0-...-37d848b Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2020 License: MIT Imports: 7 Imported by: 0

README

GitHub Workflow Status Go Report Card

niller

niller (nil + killer) is a static analysis tool that warns dangerous statement involving nil.

Installation

$ go get -u github.com/taiyoslime/niller/cmd/niller

Usage

$ go vet -vettool=$(which niller)

Example

package a

import "errors"

type Test struct { val int }

func (t *Test) test() int { return t.val }

func CreateTest(cond bool) (*Test, error) {
	if cond {
		return &Test{}, nil
	} else {
		return nil, errors.New("err")
	}
}

func f() interface{} {
	var a = &Test{}
	var b *Test
	c, _ := CreateTest(true)
	d, err := CreateTest(true)
	if err != nil {
		return err
	}
	var e *Test
	if e, err = CreateTest(true); err != nil {
		return err
	}
	var (
		f *Test
	)

	a.test()
	b.test() // warns "b may be nil"
	c.test() // warns "c may be nil"
	d.test()
	e.test()
	f.test() // warns "f may be nil"
	return nil
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name: "niller",
	Doc:  doc,
	Run:  run,
	Requires: []*analysis.Analyzer{
		inspect.Analyzer,
	},
}

Analyzer is ...

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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