Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: about 1 month 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 (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-07-23T20:53:27.000Z (over 5 years ago)
- Last Synced: 2024-06-20T13:31:15.926Z (7 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
}
```