Comments (5)
Hi! Thank you very much for filling the issue.
Just wanted to let you know that I've been very busy this year, but now I'm starting to have time again. So I expect to have time to review this soon 😉
from enumer.
from enumer.
I haven't had the time to check your master branch but, from the top of my mind, this is what I think:
- I would like to avoid adding things that are specific to certain projects or areas (other than "Enums"), as it would complicate a lot its maintenance and reusability.
- After reading your issue, I think that what you are looking for is something like the
enum.values()
method in Java which returns an array with all the values of the enum. I think this is a good addition, as it is general and tightly coupled with Enums (and nothing else).
So you could call the values()
method and do what you want with the array of values, like converting them to strings and joining the values together as a comma-separated list.
Let's see if I can buy some extra time and add this method 😉
from enumer.
from enumer.
The new version of enumer
has some additions that can be used to achieve this.
Your example would be like this (not checked):
// Assuming the enum is called UserTypes
func GetUser() interface{} {
userTypesString := strings.Trim(strings.Replace(fmt.Sprint(UserTypesValues()), " ", "','", -1), "[]")
return db.Exec(fmt.Sprintf(`
SELECT *
FROM USERS
WHERE
USERNAME=$1
AND
TYPE IN ('%s')`, userTypesString), username)
}
Thanks for your feedback and code!
from enumer.
Related Issues (20)
- Support for go 1.9 HOT 2
- can't find import HOT 2
- enumer does not convert enum keys of map to strings on JSON Marshal HOT 3
- Add -linecomment flag to enumer based on x/tools/cmd/stringer HOT 16
- Doesn't work with go modules HOT 7
- usage message is slightly-wrong HOT 1
- Improvement: Whitespace transform? HOT 3
- Failure w/ go 1.12.1 HOT 4
- could not import sync HOT 2
- invalid cross-device link HOT 5
- Make marshaling unknown values error HOT 5
- writes to `<type>_enumer.go` by default, not `<type>_string.go` HOT 2
- Wishlist: Add a -trimsuffix option HOT 1
- suggestion: Use constant names rather than literals HOT 5
- Make type to string conversion case insensitive
- You should update `/x/tools` dependency
- Add ability to parse nil value as empty string
- Go 1.18 compatibility: internal error HOT 1
- Go 1.19: conflict with doc comments
- Whishlist: support custom transformer
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from enumer.