vendredi 5 juin 2020

Retrieve the field name passed to a func with go

For example, from the main I have :


    func main() {
        m := models.NewMessage()
        dQueryBuilder := GetDeleteQueryBuilder(m)
        dQueryBuilder.Where(map[interface{}]interface{}{m.IdMessage: 9})
    }

and I don't how to get the IdMessage string in the Where method.


    func (deleteQueryBuilder *DeleteQueryBuilder) Where(mapFilter map[interface{}]interface{}) 
     *DeleteQueryBuilder {
        for key, _ := range mapFilter {
            fmt.Println(reflect.Type(key))
        }
        return deleteQueryBuilder
    }

I tried this but it return the type of the value of my field.

Need help :)





Aucun commentaire:

Enregistrer un commentaire