Skip to content
/ iferr Public
forked from koron/iferr

Generate "if err != nil {" block

License

Notifications You must be signed in to change notification settings

aca/iferr

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Generate "if err != nil {" block

Generate if err != nil { block for current function.

Usage

Install and update by

$ go get -u github.com/koron/iferr

Run, it get if err != nil { block for the postion at 1234 bytes.

$ iferr -pos 1234 < main.go
if err != nil {
	return ""
}

Vim plugin

Copy vim/ftplugin/go/iferr.vim as ~/.vim/ftplugin/go/iferr.vim.

It defines :IfErr command for go filetype. It will insert if err != nil { block at next line of the cursor.

Before:

package foo

import "io"

func Foo() (io.Reader, error) { // the cursor on this line.
}

Run :IfErr then you will get:

package foo

import "io"

func Foo() (io.Reader, error) {
	if err != nil {
		return nil, err
	}
} // new cursor is at here.

About

Generate "if err != nil {" block

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 94.2%
  • Vim Script 5.8%