goreturns

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

  • 所有者: sqs/goreturns
  • 平台:
  • 許可證: Other
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

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 15:48:08
推送於2023-10-30 19:15:05
最后一次提交2020-10-17 19:32:42
發布數0
用户参与
星數534
關注者數10
派生數53
提交數39
已啟用問題?
問題數42
打開的問題數22
拉請求數14
打開的拉請求數5
關閉的拉請求數3
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?