The docs note that you can chain queries like this:
db.Where("name <> ?","jinzhu").Where("age >= ? and role <> ?",20,"admin").Find(&users)
Is that what you’re looking for? Alternately you could conditionally construct structs to pass to the query:
func query(name, age) {
var user *User
if someCondition {
user = &User{name: name, age: age}
} else {
user = &User{name: name}
db.Where(user).First(&user)
}