Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type JSONColumn ¶
type JSONColumn spanner.GenericColumnValue
JSONColumn is an encodable type of spanner.GenericColumnValue.
func (*JSONColumn) MarshalJSON ¶
func (c *JSONColumn) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler
type JSONObject ¶
type JSONObject interface { Set(key string, value interface{}) Get(key string) (interface{}, bool) Ref() string }
JSONObject is interface of JSON object.
type JSONRow ¶
JSONRow is an encodable type of spanner.Row.
func (*JSONRow) JSONSchema ¶
Schema writes JSON Schema of the row to writer w.
func (*JSONRow) MarshalJSON ¶
MarshalJSON implements json.Marshaler
type JSONRows ¶
JSONRows is an encodable type of []*spanner.Row.
func (JSONRows) JSONSchema ¶
Schema writes JSON Schema of the rows to writer w.
func (JSONRows) MarshalJSON ¶
MarshalJSON implements json.Marshaler
type RecordWriter ¶
RecordWriter writes a record. csv.Writer implements RecordWriter.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer is writes *spanner.Row to Recordwriter.
func (*Writer) Write ¶
Write writes a row of spanner to RecordWriter. If it is first time to write, Write writes also a header before writing a row. When second argument of NewWriter is false, the header would be omit.
Example with csv.Writer:
func query(ctx context.Context, w io.Writer, client *spanner.Client) error { stmt := spanner.Statement{SQL: `SELECT * FROM mytable`} iter := client.Single().Query(ctx, stmt) defer iter.Stop() cw := csv.NewWriter(w) hw := hake.NewWriter(cw, true) for { row, err := iter.Next() switch { case err == iterator.Done: return nil case err != nil: return err } if err := hw.Write(row); err != nil { return err } cw.Flush() } }