package postgres import ( "github.com/kcotugno/tacitus" "database/sql" "errors" ) type TradeResults struct { rows *sql.Rows trade tacitus.Trade err error } func (r *TradeResults) Next() bool { var t tacitus.Trade var done bool if r.rows == nil { r.err = errors.New("No query results") return false } if r.rows.Next() { r.err = r.rows.Scan(&t.Id, &t.TradeId, &t.Product, &t.Price, &t.Size, &t.Buy, &t.Sell, &t.Timestamp) r.trade = t } else { done = true r.err = r.rows.Err() } if r.err == nil && !done { return true } else { return false } } func (r *TradeResults) Value() interface{} { return r.trade } func (r *TradeResults) Error() error { return r.err } func (r *TradeResults) Close() error { if r.rows != nil { return r.rows.Close() } return nil }