go-enum
An enum generator for go (by abice)
goderive
Derives and generates mundane golang functions that you do not want to maintain yourself (by awalterschulze)
go-enum | goderive | |
---|---|---|
8 | 3 | |
818 | 1,257 | |
2.8% | 0.8% | |
3.4 | 6.5 | |
30 days ago | about 1 month ago | |
Go | Go | |
MIT License | Apache License 2.0 |
The number of mentions indicates the total number of mentions that we've tracked plus the number of user suggested alternatives.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
go-enum
Posts with mentions or reviews of go-enum.
We have used some of these posts to build our list of alternatives
and similar projects. The last one was on 2024-07-12.
-
Enums in Go
There's also https://github.com/abice/go-enum, which I decided to use after evaluating multiple such tools a while ago, but I don't remember exactly why it came out on top for me. Also, both (and others) have evolved since then, so things might have changed.
One nice thing go-enum does is to even generate the consts, just from a list of values in a comment.
-
Ten Years of “Go: The Good, the Bad, and the Meh
While not perfect, there are ways to generate enums automatically using go:generate, e.g. https://github.com/abice/go-enum
-
Go vs Rust
I wouldn't write a macro to save a couple of lines, but I would definitely use (not even write, just use) a macro for something like generating enum [de]serialization for both JSON and BSON in one line. Go, even with generics, still has no way of abstracting extremely common patterns like enums without separate generator tools. Clearly someone thought the macro was useful here, but without a macro they had no choice but to write a separate tool.
-
Enums?
Ive found enums in Go are a pain point, especially across an organization because there are many valid ways to implement it. It's also fairly verbose to implement. The way Ive solved for it is code generation. This is a pretty good library that my team uses in production https://github.com/abice/go-enum
-
Why no enums?
I've worked in a few different languages and Go doesn't seem all that unique in the way that it doesn't provide an ENUM primitive. However, I looked around a bit and found go-enum which seems pretty neat. Also, I have no problem writing a custom string or int/iota type. In some cases you want to be able to serialize/deserialize with them -- and in others you don't need that.
-
Does Go not have enums in the sense that I can use them as a type?
Along that same line you can take it a step further and generate the iota block too with this tool https://github.com/abice/go-enum
-
How to do Enums in Go
Looks like this does what you want: https://github.com/abice/go-enum
goderive
Posts with mentions or reviews of goderive.
We have used some of these posts to build our list of alternatives
and similar projects. The last one was on 2022-09-10.
-
Do you generate Clone or Copy methods?
I found https://github.com/awalterschulze/goderive but haven't used anything like it besides mockgen
-
Why GoLang supports null references if they are billion dollar mistake?
Now, am I going to do the same with a library like goderive just so I can use FP techniques to get, amongst some other things, less nil checks? No. Probably not. If I wanted to use primarily FP techniques in my code, I would probably be using something else in the first place. Go isn't a great environment for guaranteeing immutability for starters, so anything like that is necessarily going to be an incomplete experience. And in the bargain, my code would, in my opinion at least, be less readable and maintainable.
- Derives mundane Golang functions that you do not want to maintain
What are some alternatives?
When comparing go-enum and goderive you can also consider the following projects:
gotype - Golang source code parsing, usage like reflect package
typeregistry - create type dynamically in Golang
GoWrap - GoWrap is a command line tool for generating decorators for Go interfaces
goverter - Generate type-safe Go converters by defining function signatures.
generis - Versatile Go code generator.