Giter Club home page Giter Club logo

enumer's Introduction

enumer

一直在思考go语言中枚举的一个良好的使用方式,这个工具是根据我自己的枚举使用规范来生成枚举代码。

enumer -e {enumName} -o {output} -p {package}

该命令会生成一个int类型的type,名字为枚举名,并且默认生成了两个不需要的类型 _name_Unknown和_name_UnknownEnd

并且会有一个Valid方法可以判断枚举是否合法,并且还在枚举类型上注释添加了go:generate,可以通过stringer来生成枚举的String方法。

要新加枚举值只需要在_name_Unknown和_name_UnknownEnd中间插入值即可,然后generate一下更新string方法,所有使用到 IsValid方法的地方都不用修改。

enumer's People

Contributors

soluty avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.