func (r *Rows) Next(dest []driver.Value) error {
	if r.pos >= r.rowcount {
		return io.EOF
	}
	for i := range dest {
		dest[i] = r.values[r.pos][i]
	}
	r.pos++
	return nil
}
Get the next row
package crate
import (
	"bytes"
	"database/sql"
	"database/sql/driver"
	"encoding/json"
	"errors"
	"fmt"
	"io"
	"io/ioutil"
	"net/http"
	"net/url"
)
type CrateDriver struct {
	Url        string  
	username   string
	password   string
	httpClient *http.Client
}
func (c *CrateDriver) Open(crate_url string) (driver.Conn, error) {
	u, err := url.Parse(crate_url)
	if err != nil {
		return nil, err
	}
	sanUrl := fmt.Sprintf("%s://%s", u.Scheme, u.Host)
	c.Url = sanUrl
	c.httpClient = &http.Client{}
	if u.User != nil {
		username := u.User.Username()
		password, _ := u.User.Password()
		c.username = username
		c.password = password
	}
	return c, nil
}
type endpointResponse struct {
	Error struct {
		Message string
		Code    int
	} `json:"error"`
	Cols        []string        `json:"cols"`
	Duration    float64         `json:"duration"`
	ColumnTypes []interface{}   `json:"col_types"`
	Rowcount    int64           `json:"rowcount"`
	Rows        [][]interface{} `json:"rows"`
}
type endpointQuery struct {
	Stmt string         `json:"stmt"`
	Args []driver.Value `json:"args,omitempty"`
}
func (c *CrateDriver) query(stmt string, args []driver.Value) (*endpointResponse, error) {
	endpoint := c.Url + "/_sql?types"
	query := &endpointQuery{
		Stmt: stmt,
	}
	if len(args) > 0 {
		query.Args = args
	}
	buf, err := json.Marshal(query)
	if err != nil {
		return nil, err
	}
	data := bytes.NewReader(buf)
	req, err := http.NewRequest("POST", endpoint, data)
	if err != nil {
		return nil, err
	}
	if c.username != "" {
		req.SetBasicAuth(c.username, c.password)
	}
	req.Header.Add("Content-Type", "application/json")
	resp, err := c.httpClient.Do(req)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()
	if resp.StatusCode >= 200 && resp.StatusCode <= 299 {
		res := &endpointResponse{}
		d := json.NewDecoder(resp.Body)
		d.UseNumber()
		err = d.Decode(res)
		if err != nil {
			return nil, err
		}
		if res.Error.Code != 0 {
			err = &CrateErr{
				Code:    res.Error.Code,
				Message: res.Error.Message,
			}
			return nil, err
		}
		return res, nil
	} else {
		body, err := ioutil.ReadAll(resp.Body)
		if err != nil {
			return nil, err
		}
		msg := fmt.Sprintf("Invalid http status code %d, body: %s", resp.StatusCode, string(body))
		return nil, errors.New(msg)
	}
}
func (c *CrateDriver) Query(stmt string, args []driver.Value) (driver.Rows, error) {
	res, err := c.query(stmt, args)
	if err != nil {
		return nil, err
	}
	rows := &Rows{
		columns:  res.Cols,
		values:   res.Rows,
		rowcount: res.Rowcount,
	}
	return rows, nil
}
func (c *CrateDriver) Exec(stmt string, args []driver.Value) (result driver.Result, err error) {
	res, err := c.query(stmt, args)
	if err != nil {
		return nil, err
	}
	result = &Result{res.Rowcount}
	return result, nil
}
type Result struct {
	affectedRows int64
}
func (r *Result) LastInsertId() (int64, error) {
	err := errors.New("LastInsertId() not supported.")
	return 0, err
}
func (r *Result) RowsAffected() (int64, error) {
	return r.affectedRows, nil
}
type Rows struct {
	columns  []string
	values   [][]interface{}
	rowcount int64
	pos      int64  
}
func (r *Rows) Columns() []string {
	return r.columns
}