Can declare constant's into struct?

If it’s about having the struct describe which fields to select from, take a look at https://github.com/jmoiron/sqlx for some useful shortcuts on top of the standard library. You might also want to make the select thing a method of the type itself, so the definition is close to the struct definition.

You cannot have struct fields named by some constant in the same code, excerpt by using code generation or (possibly) reflect. Don’t go there until you are very familiar with all aspects of Go and still think it’s a good idea.

2 Likes