deferresult

command module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2021 License: MIT Imports: 2 Imported by: 0

README

deferresult

Motivation

Unhandled error in defer statement is always a problem. We have some wrapper utilities in our project to eat errors with Logger looks like this:

func (l *logger) Wrap(f func() error, msg string) func() {
	return func() {
		err := f()
		// log the err down
    }
}

But that caused another trap: defer logger.Wrap(resource.Close, "closing resource") would NOT close the resource since the func() returned by Wrap is not called!

Basically we found that expression in defer should never return anything so this linter is created to check about this.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

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