func (attr *String) Encode(w *pgx.WriteBuf, oid pgx.Oid) error { switch attr.Status { case Present: return pgx.Encode(w, oid, attr.Value) case Null: w.WriteInt32(-1) return nil case Undefined: return errors.New("cannot encode undefined attr") default: panic("unreachable") } }
func (attr *IPNet) Encode(w *pgx.WriteBuf, oid pgx.Oid) error { if oid != pgx.InetOid && oid != pgx.CidrOid { return pgx.SerializationError(fmt.Sprintf("IPNet.Encode cannot encode into OID %d", oid)) } switch attr.Status { case Present: return pgx.Encode(w, oid, attr.Value) case Null: w.WriteInt32(-1) return nil case Undefined: return errors.New("cannot encode undefined attr") default: panic("unreachable") } }