Пример #1
0
func (b bytea) Encode(w *pgx.WriteBuf, oid pgx.Oid) error {
	if len(b) == 0 {
		w.WriteInt32(-1)
		return nil
	}
	w.WriteInt32(int32(len(b)))
	w.WriteBytes(b)
	return nil
}
Пример #2
0
func (p NullPoint) Encode(w *pgx.WriteBuf, oid pgx.Oid) error {
	if !p.Valid {
		w.WriteInt32(-1)
		return nil
	}

	s := fmt.Sprintf("point(%v,%v)", p.X, p.Y)
	w.WriteInt32(int32(len(s)))
	w.WriteBytes([]byte(s))

	return nil
}
Пример #3
0
func (n *coreEncoder) Encode(w *pgx.WriteBuf, oid pgx.Oid) error {
	w.WriteInt32(int32(2))
	w.WriteBytes([]byte("42"))
	return nil
}