defermodafterreturn

command module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2023 License: MIT Imports: 11 Imported by: 0

README

defermodafterreturn

A Go (golang) tool for detecting defers that attempt to modify a non-named return value

Installing

go install github.com/simplylib/defermodafterreturn@latest

Usage

defermodafterreturn detects uses of a defer that attempts to modify return values in a function without named returns

Usage: defermodafterreturn [flags] <dir/file>

Ex: defermodafterreturn -v -t 8 . // recursively find all go files in current directory and scan for defers

Flags:
  -t int
        how many files to work on at once (default is number of cpu threads)
  -v    be verbose about operations

Example

Running defermodafterreturn linter/testdata/bad.go inside of this repo on this file

linter/testdata/bad.go:11:8 function literal in defer assigns to non-named return in parent function
defer func() {
        err2 := w.Close()
        if err2 != nil && err != nil {
                err = err2
        }
}()

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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