Have you thought about SQL builder ?
eg:

A great many possibilities
@zxysilent, I recommend you to take a look at https://github.com/Masterminds/squirrel. I'm using it currently for my project. It's quite simple:
func Select(cols string, destination interface{}, where sq.Eq, db *sqlx.DB) error {
// build query using squirrel
query, args, _ := sq.Select(cols).From(Table).Where(where).ToSql()
// Run query using sqlx
return db.Get(destination, query, args...)
}
Most helpful comment
@zxysilent, I recommend you to take a look at https://github.com/Masterminds/squirrel. I'm using it currently for my project. It's quite simple: