All Projects → therne → stringenum

therne / stringenum

Licence: other
A go tool to auto-generate methods for enum types based on string.

Programming Languages

go
31211 projects - #10 most used programming language

Labels

Projects that are alternatives of or similar to stringenum

auto-commit-msg
A VS Code extension to generate a smart commit message based on file changes
Stars: ✭ 61 (+335.71%)
Mutual labels:  generate
c2ats
generate ATS interface from C code
Stars: ✭ 19 (+35.71%)
Mutual labels:  generate
python-makefun
Dynamically create python functions with a proper signature.
Stars: ✭ 62 (+342.86%)
Mutual labels:  generate
readme-generator
Generate a readme from a template and package.json data. If you need something more comprehensive, I recommend using Verb.
Stars: ✭ 18 (+28.57%)
Mutual labels:  generate
generative
A digital playground for experimenting with creative coding and WebGL
Stars: ✭ 50 (+257.14%)
Mutual labels:  generate
DictGenerate
使用Go语言编写的社工字典生成器(The social engineering dictionary generator written by Go)
Stars: ✭ 64 (+357.14%)
Mutual labels:  generate
okty
The simplest application to create and customize your docker projects
Stars: ✭ 48 (+242.86%)
Mutual labels:  generate
mosaic-node-generator
Generate mosaic images in Node.
Stars: ✭ 25 (+78.57%)
Mutual labels:  generate
abstract-syntax-tree
A library for working with abstract syntax trees.
Stars: ✭ 77 (+450%)
Mutual labels:  generate
SwitchCaseGenerator
An Xcode Source Editor Extension that generates a swift switch case statement based on selected enum cases
Stars: ✭ 63 (+350%)
Mutual labels:  generate
contextual
🌈 Generate your Ecto contexts using this macro and eliminate boilerplate
Stars: ✭ 18 (+28.57%)
Mutual labels:  generate
BitBruteForce-Wallet
No description or website provided.
Stars: ✭ 142 (+914.29%)
Mutual labels:  generate
SwiftPackage
🏆 Template to make a Swift package
Stars: ✭ 37 (+164.29%)
Mutual labels:  generate
browserslist-generator
A library that makes generating and validating Browserslists a breeze!
Stars: ✭ 77 (+450%)
Mutual labels:  generate
flutter-openpgp
OpenPGP for flutter made with golang for fast performance with support for android, ios, macos, linux, windows, web and hover
Stars: ✭ 35 (+150%)
Mutual labels:  generate
test-data-generation
Test Data Generation
Stars: ✭ 35 (+150%)
Mutual labels:  generate
graphql-directive-sql
Unify your SQL schema and your GraphQL Schema. Use GraphQL SDL as the lingua franca to define your data requirements.
Stars: ✭ 28 (+100%)
Mutual labels:  generate
ecto generator
Generate Ecto schemas from existing database in Phoenix - Elixir
Stars: ✭ 20 (+42.86%)
Mutual labels:  generate
TyStrings
strings file tool for iOS / macOS developers
Stars: ✭ 15 (+7.14%)
Mutual labels:  generate
QuestPDF
QuestPDF is an open-source, modern and battle-tested library that can help you with generating PDF documents by offering friendly, discoverable and predictable C# fluent API.
Stars: ✭ 2,872 (+20414.29%)
Mutual labels:  generate

stringenum

A go tool to auto-generate serialization / validation methods for enum types aliasing string.

Features

  • Supports JSON, YAML serialization
  • Implements Validator interface
  • Does not support default values yet. But it has good fit with third-party default value modules like creasty/defaults because your types are basically a string!

Installation

You need to install stringenum to generate enum stub codes.

 $ go get github.com/therne/stringenum/...

Usage

On the top of your type definition sources, add go generate clause to generate stub codes with stringenum.

+ //go:generate stringenum Kind
package mytype

type Kind string

const (
    Apple  = Kind("apple")
    Google = Kind("google")
)

Then, run go generate to generate stub codes:

 $ go generate ./...

Generated Values and Methods

  • <Type>Values: A list of all available values in the enum.
  • <Type>FromString(string): Casts string into the enum. An error is returned if given string is not defined on the enum.
  • IsValid(): Returns false if the value is not defined on the enum.
  • Validate(): Returns an error if the value is not defined on the enum.
  • MarshalText / UnmarshalText: Implements encoding.TextMarshaler / TextUnmarshaler interface for JSON / YAML serialization.
  • String() : Casts the enum into a string. Implements fmt.Stringer interface.

License: MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].