Documentation
¶
Index ¶
- Constants
- Variables
- func Map(target interface{}, useTag string) (map[string]interface{}, error)
- func Scan(rows Rows, target interface{}) error
- func ScanClose(rows Rows, target interface{}) error
- func ScanMap(rows Rows) ([]map[string]interface{}, error)
- func ScanMapClose(rows Rows) ([]map[string]interface{}, error)
- func ScanMapDecode(rows Rows) ([]map[string]interface{}, error)
- func ScanMapDecodeClose(rows Rows) ([]map[string]interface{}, error)
- func SetTagName(name string)
- type ByteUnmarshaler
- type CloseErr
- type Rows
- type ScanErr
Constants ¶
const (
// DefaultTagName is the default struct tag name
DefaultTagName = "ddb"
)
Variables ¶
var ( //ErrTargetNotSettable means the second param of Bind is not settable ErrTargetNotSettable = errors.New("[scanner]: target is not settable! a pointer is required") //ErrNilRows means the first param can't be a nil ErrNilRows = errors.New("[scanner]: rows can't be nil") //ErrSliceToString means only []uint8 can be transmuted into string ErrSliceToString = errors.New("[scanner]: can't transmute a non-uint8 slice to string") //ErrEmptyResult occurs when target of Scan isn't slice and the result of the query is empty ErrEmptyResult = errors.New(`[scanner]: empty result`) )
var ( // ErrNoneStructTarget as its name says ErrNoneStructTarget = errors.New("[scanner] target must be a struct type") )
Functions ¶
func Scan ¶
Scan scans data from rows to target Don't forget to close the rows When the target is not a pointer of slice, ErrEmptyResult may be returned if the query result is empty
func ScanClose ¶
ScanClose is the same as Scan and helps you Close the rows Not necessary exec the rows.Close after calling this. Close is idempotent and does not affect the result of Err.
func ScanMap ¶
ScanMap returns the result in the form of []map[string]interface{} json.Marshal encodes []byte as a base64 string, while in most cases it's expected to be encoded as string or int. If you want this, use ScanMapDecode instead.
func ScanMapClose ¶
ScanMapClose is the same as ScanMap and close the rows
func ScanMapDecode ¶
ScanMapDecode returns the result in the form of []map[string]interface{} If possible, it will convert []uint8 to int or float64, or it will convert []uint8 to string
func ScanMapDecodeClose ¶
ScanMapDecodeClose returns the result in the form of []map[string]interface{} If possible, it will convert []uint8 to int or float64, or it will convert []uint8 to string. It will close the rows in the end.
Types ¶
type ByteUnmarshaler ¶
ByteUnmarshaler is the interface implemented by types that can unmarshal a JSON description of themselves. The input can be assumed to be a valid encoding of a JSON value. UnmarshalByte must copy the JSON data if it wishes to retain the data after returning.
By convention, to approximate the behavior of Unmarshal itself, ByteUnmarshaler implement UnmarshalByte([]byte("null")) as a no-op.
type CloseErr ¶
type CloseErr struct {
// contains filtered or unexported fields
}
CloseErr is the error occurs when rows.Close()