package main import ( "database/sql" "fmt" "log" _ "github.com/lib/pq" ) // FileT - file db schema type FileT struct { ID string `db:"id"` Name string `db:"name"` } func main() { connStr := "postgres://postgres@localhost:5432/mystorage?sslmode=disable" db, err := sql.Open("postgres", connStr) handleError(err) rows, err := db.Query(`select id, name from "storage"."files" where "tmp" = $1 and "trash" = $2 limit 2`, false, false) handleError(err) var id, name string for rows.Next() { rows.Scan(&id, &name) fmt.Printf("id: %s, name: %s \n", id, name) } } func handleError(err error) { if err != nil { log.Fatal(err) } }