https://github.com/reiver/gogen-optiontype
Option types (also known as maybe types) for Go, via "go generate".
https://github.com/reiver/gogen-optiontype
go-generate go-generics option-type
Last synced: 4 months ago
JSON representation
Option types (also known as maybe types) for Go, via "go generate".
- Host: GitHub
- URL: https://github.com/reiver/gogen-optiontype
- Owner: reiver
- License: mit
- Created: 2017-05-10T22:36:19.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-07-23T20:53:27.000Z (almost 6 years ago)
- Last Synced: 2025-01-25T13:08:23.829Z (6 months ago)
- Topics: go-generate, go-generics, option-type
- Language: Go
- Size: 102 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gogen-optiontype
Option types (also known as maybe types) for Go programming language, via `go generate`.
# Usage
```go
package itemid//go:generate gogen-optiontype --pkg=itemid --type=int64
```
```go
package thingid//go:generate gogen-optiontype --pkg=thingid --type=string --one-file
```
```go
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](https://getgb.io/).)Can then use with code similar to:
```
type Struct Product {
ID productid.Type
Name string
ItemID itemid.NullableType
}
```