goreturns

A gofmt/goimports-like tool for Go programmers that fills in Go return statements with zero values to match the func return types

Github星跟踪图

This tool adds zero-value return values to incomplete Go return
statements, to save you time when writing Go. It is inspired by
and based on goimports.

short screencast

full 30-second screencast: http://youtu.be/hyEMO9vtKZ8

For example, the following incomplete return statement:

func F() (*MyType, int, error) { return errors.New("foo") }

is made complete by adding nil and 0 returns (the zero values for
*MyType and int):

func F() (*MyType, int, error) { return nil, 0, errors.New("foo") }

To install:

go get -u github.com/sqs/goreturns

To run:

goreturns file.go

To view a diff showing what it'd do on a sample file:

goreturns -d $GOPATH/github.com/sqs/goreturns/_sample/a.go

Editor integration: replace gofmt or goimports in your post-save hook
with goreturns. By default goreturns calls goimports on files before
performing its own processing.

It acts the same as gofmt (same flags, etc) but in addition to code
formatting, also fixes returns.

主要指标

概览
名称与所有者sqs/goreturns
主编程语言Go
编程语言Go (语言数: 1)
平台
许可证Other
所有者活动
创建于2014-10-07 23:48:08
推送于2023-10-31 03:15:05
最后一次提交2020-10-18 03:32:42
发布数0
用户参与
星数536
关注者数7
派生数53
提交数39
已启用问题?
问题数42
打开的问题数22
拉请求数14
打开的拉请求数5
关闭的拉请求数3
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?