package main

import (
    "fmt"
    "log"
    
    _ "github.com/mattn/go-sqlite3"
    "github.com/jmoiron/sqlx"
    sq "github.com/Masterminds/squirrel"
)


type Person struct {
    FirstName string `db:"first_name"`
    LastName  string `db:"last_name"`
    Email     string
}

func main() {
    db, err := sqlx.Connect("sqlite3", "test.sqlite3")
    if err != nil {
        log.Fatalln(err)
    }

    sql, args, err := sq.Select("*").From("person").Where(sq.Eq{"first_name": "Zed"}).ToSql()
    if err != nil {
      log.Fatalln(err);
    }

    fmt.Println(sql, args)

    jason := Person{}
    err = db.Get(&jason, sql, args...)

    if err != nil {
      log.Fatalln(err);
    }

    fmt.Printf("%#v\n", jason)
}
