Version: v0.0.0-...-bd14a5d Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2016 License: MIT, MIT Imports: 6 Imported by: 0



The types package provides some useful types which implement the sql.Scanner and driver.Valuer interfaces, suitable for use as scan and value targets with database/sql.




This section is empty.


This section is empty.


This section is empty.


type GzippedText

type GzippedText []byte

GzippedText is a []byte which transparently gzips data being submitted to a database and ungzips data being Scanned from a database.

func (*GzippedText) Scan

func (g *GzippedText) Scan(src interface{}) error

Scan implements the sql.Scanner interface, ungzipping the value coming off the wire and storing the raw result in the GzippedText.

func (GzippedText) Value

func (g GzippedText) Value() (driver.Value, error)

Value implements the driver.Valuer interface, gzipping the raw value of this GzippedText.

type JsonText

type JsonText json.RawMessage

JsonText is a json.RawMessage, which is a []byte underneath. Value() validates the json format in the source, and returns an error if the json is not valid. Scan does no validation. JsonText additionally implements `Unmarshal`, which unmarshals the json within to an interface{}

func (*JsonText) MarshalJSON

func (j *JsonText) MarshalJSON() ([]byte, error)

MarshalJSON returns the *j as the JSON encoding of j.

func (*JsonText) Scan

func (j *JsonText) Scan(src interface{}) error

Scan stores the src in *j. No validation is done.

func (JsonText) String

func (j JsonText) String() string

Pretty printing for JsonText types

func (*JsonText) Unmarshal

func (j *JsonText) Unmarshal(v interface{}) error

Unmarshal unmarshal's the json in j to v, as in json.Unmarshal.

func (*JsonText) UnmarshalJSON

func (j *JsonText) UnmarshalJSON(data []byte) error

UnmarshalJSON sets *j to a copy of data

func (JsonText) Value

func (j JsonText) Value() (driver.Value, error)

Value returns j as a value. This does a validating unmarshal into another RawMessage. If j is invalid json, it returns an error.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL