I encapsulate db rows with a struct
type myThingy {
col1 string
col2 int
}
but when writing a query function, I have to type out the name of the column
queryThingy(col1Val string) {
return db.queryf("SELECT * WHERE col1==%s", col1Val)
}
I would much rather have some sort of const to use instead
queryThingy(colKey string, colVal string) {
return db.queryf("SELECT * WHERE %s==%s",colKey, colVal)
}
however since I already have myThingy
type, I would just like to take the struct field names and turn it into a set of constants that i can use to specify the column names in my db
obviously this is a toy example but the pattern would be useful to me