enumall

command module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2022 License: MIT Imports: 11 Imported by: 0

README

Enumall

Go

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.

//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 contaings all const values is All{$typeName}

// Code generated by "enumall -type=Season"; DO NOT EDIT.

package main

var AllSeason = []Season{
	Spring,
	Summer,
	Autumn,
	Winter,
}

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL