Skip to content

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

License

Notifications You must be signed in to change notification settings

reiver/gogen-optiontype

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
}

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages