func (p *PrestScanner) Scan(i interface{}) (l int, err error) {
	var ref reflect.Value
	log.Debugln("database return:", string(p.Buff.Bytes()))
	if ref, err = validateType(i); err != nil {
		return
	}
	if p.IsQuery {
		l, err = p.scanQuery(ref, i)
		return
	}
	l, err = p.scanNotQuery(ref, i)
	return
}
Scan put prest response into a struct or map
package scanner
import (
	"bytes"
	"encoding/json"
	"errors"
	"reflect"
	"github.com/nuveo/log"
)
var (
	errPtr      = errors.New("item to input data is not a pointer")
	errUnsupTyp = errors.New("item to input data has an unsupported type")
	errLength   = errors.New("rows returned is not 1")
	supType     = map[reflect.Kind]bool{
		reflect.Slice:  true,
		reflect.Struct: true,
		reflect.Map:    true,
	}
)
func validateType(i interface{}) (ref reflect.Value, err error) {
	ref = reflect.ValueOf(i)
	if ref.Kind() != reflect.Ptr {
		err = errPtr
		return
	}
	if _, ok := supType[ref.Elem().Kind()]; !ok {
		err = errUnsupTyp
		return
	}
	return
}
type PrestScanner struct {
	Buff    *bytes.Buffer
	Error   error
	IsQuery bool
}