Option types (also known as maybe types) for Go programming language, via go generate
.
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
}