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 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 { r.err = r.rows.Err() return false } if r.err == nil { 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 }