https://github.com/tomaspavlic/enumall
Enumall is a tool to automate the creation of all const values for given type (enum)
https://github.com/tomaspavlic/enumall
all codegenerator enum go golang
Last synced: 24 days ago
JSON representation
Enumall is a tool to automate the creation of all const values for given type (enum)
- Host: GitHub
- URL: https://github.com/tomaspavlic/enumall
- Owner: tomaspavlic
- License: mit
- Created: 2022-07-05T08:51:11.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-07-05T09:21:08.000Z (over 3 years ago)
- Last Synced: 2024-06-20T22:35:25.509Z (over 1 year ago)
- Topics: all, codegenerator, enum, go, golang
- Language: Go
- Homepage:
- Size: 4.88 KB
- Stars: 9
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Enumall
[](https://github.com/tomaspavlic/enumall/actions/workflows/go.yml)
Enumall is a tool to automate the creation of all const values for given type (enum).
## Installation
`enumall` is installable command line application.
```
go install github.com/tomaspavlic/enumall
```
## Usage
Add Go's code generator comment to use `enumall`.
```golang
//go:generate go run github.com/tomaspavlic/enumall@latest -type=Season
type Season uint8
const (
Spring Season = 1 << iota
Summer
Autumn
Winter
)
```
Run code generator inside your module.
```
go generate ./...
```
Generated code is named `{$typeName}_all.go`. Variable containing all const values is `All{$typeName}`
```golang
// Code generated by "enumall -type=Season"; DO NOT EDIT.
package main
var AllSeason = []Season{
Spring,
Summer,
Autumn,
Winter,
}
```