How can I build a dynamic query depending on the parameters that I get?

This example is stupid and the syntax is wrong but you will get the idea of what I want.

I guess that I need to add a slice of variables to the end of the query.

I know how to do it in PHP, but not in golang.

db := OpenDB()

defer db.Close()

var filter string

if name != "" {     
filter = filter " AND name = ?" 

}

if surname != "" {  
filter = filter + " AND surname = ?"

}

if address != "" {  
filter =  filter + " AND address = ?" 

}

err = db.Query("SELECT id FROM users WHERE login = ?" +
filter, login)