I find that when I am working on a project it often simplifies things to define variables or constants that represent database ID fields. In golang I have a constants.go file with
const (
//SELECT ID FROM dbo.MyTable
MYTABLEID_NO = 1 // MyTable ID for NO
MYTABLEID_YES = 2 // MyTable ID for YES
MYTABLEID_MAYBE = 3 // MyTable ID for MAYBE
)
Is this considered bad practice? how might I get around doing this if it is? Is there a more dynamic way of doing this in golang? If for some reason an ID changes, new IDs are added or the table has many IDs this way of doing things starts to break down.