Git Product home page Git Product logo

Comments (5)

alvaroloes avatar alvaroloes commented on July 22, 2024

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.

gjrtimmer avatar gjrtimmer commented on July 22, 2024

from enumer.

alvaroloes avatar alvaroloes commented on July 22, 2024

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.

gjrtimmer avatar gjrtimmer commented on July 22, 2024

from enumer.

alvaroloes avatar alvaroloes commented on July 22, 2024

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)

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.