Skip to content

v4.1.0: Shorthand constructors

Compare
Choose a tag to compare
@icio icio released this 07 Nov 11:18
· 15 commits to master since this release
59f0b32

New constructor functions:

null.B(b) == null.NewBool(b, true)
null.I(i) == null.NewInt(i, true)
null.F(f) == null.NewFloat(f, true)
null.S(s) == null.NewString(s, true)
null.ZS(s) == null.NewString(s, s != "")

You can have gofmt rewrite these function calls in PATH for you with:

gofmt -w -r 'null.BoolFrom(s) -> null.B(s)' PATH
gofmt -w -r 'null.IntFrom(i) -> null.I(i)' PATH
gofmt -w -r 'null.FloatFrom(f) -> null.F(f)' PATH
gofmt -w -r 'null.TimeFrom(t) -> null.T(t)' PATH
gofmt -w -r 'null.StringFrom(s) -> null.S(s)' PATH
gofmt -w -r 'null.NewString(s, s != "") -> null.ZS(s)' PATH