Skip to content

Latest commit

 

History

History
45 lines (32 loc) · 651 Bytes

README.md

File metadata and controls

45 lines (32 loc) · 651 Bytes

gogen-optiontype

Option types (also known as maybe types) for Go programming language, via go generate.

Usage

package itemid

//go:generate gogen-optiontype --pkg=itemid --type=int64
package thingid

//go:generate gogen-optiontype --pkg=thingid --type=string --one-file
package productid

//go:generate gogen-optiontype --pkg=thingid --type=string --one-file --no-tests

And then run:

go generate

or:

gb generate

(If you are using GB.)

Can then use with code similar to:

type Struct Product {
	ID     productid.Type
	Name   string
	ItemID itemid.NullableType
}