expanderr

command module
v0.0.0-...-792eb1f Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2022 License: BSD-3-Clause Imports: 23 Imported by: 0

README

expanderr

Go Report Card

expanderr logo

The expanderr (think “expander”, pronounced with a pirate accent) is a tool which expands the Go Call Expression under your cursor to check errors. As an example, assuming your cursor is positioned on this call expression:

os.Remove("/tmp/state.bin")

…invoking the expanderr will leave you with this If Statement instead:

if err := os.Remove("/tmp/state.bin"); err != nil {
	return err
}

Of course, the return values match the enclosing function signature, functions returning more than one argument are supported, and the local scope is considered to ensure that your code still compiles.

screencast

Setup

Start by running go get -u github.com/stapelberg/expanderr. Then, follow the section for the editor you use:

Emacs

Add (load "~/go/src/github.com/stapelberg/expanderr/lisp/go-expanderr.el") to your Emacs configuration.

From now on, use C-c C-e to invoke the expanderr.

Opportunities to contribute

How does this differ from goreturns?

goreturns only inserts a return statement with zero values for the current function.

expanderr understands the signature of the call expression under your cursor and inserts the appropriate error checking statement (including a return statement). In practice, this eliminates the need of combining goreturns with an editor snippet, with the additional bonus of working correctly in a larger number of situations.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal
srcimporter
Package srcimporter implements importing directly from source files rather than installed packages.
Package srcimporter implements importing directly from source files rather than installed packages.

Jump to

Keyboard shortcuts

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