Skip to content

Commit 1e37dc2

Browse files
AnaNekoleg-jukovec
authored andcommitted
code health: place fill* functions in the beginning of the files
File `requests.go` has `fill*` functions as well as `prepare.go` file. We should sync with `requests.go` and place `fill*` functions in the beginning of `prepare.go` file. Follows up #117 Part of #101
1 parent 609268f commit 1e37dc2

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

prepared.go

+20-20
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,26 @@ type Prepared struct {
2020
Conn *Connection
2121
}
2222

23+
func fillPrepare(enc *msgpack.Encoder, expr string) error {
24+
enc.EncodeMapLen(1)
25+
enc.EncodeUint64(KeySQLText)
26+
return enc.EncodeString(expr)
27+
}
28+
29+
func fillUnprepare(enc *msgpack.Encoder, stmt Prepared) error {
30+
enc.EncodeMapLen(1)
31+
enc.EncodeUint64(KeyStmtID)
32+
return enc.EncodeUint64(uint64(stmt.StatementID))
33+
}
34+
35+
func fillExecutePrepared(enc *msgpack.Encoder, stmt Prepared, args interface{}) error {
36+
enc.EncodeMapLen(2)
37+
enc.EncodeUint64(KeyStmtID)
38+
enc.EncodeUint64(uint64(stmt.StatementID))
39+
enc.EncodeUint64(KeySQLBind)
40+
return encodeSQLBind(enc, args)
41+
}
42+
2343
// NewPreparedFromResponse constructs a Prepared object.
2444
func NewPreparedFromResponse(conn *Connection, resp *Response) (*Prepared, error) {
2545
if resp == nil {
@@ -150,23 +170,3 @@ func (req *ExecutePreparedRequest) Context(ctx context.Context) *ExecutePrepared
150170
req.ctx = ctx
151171
return req
152172
}
153-
154-
func fillPrepare(enc *msgpack.Encoder, expr string) error {
155-
enc.EncodeMapLen(1)
156-
enc.EncodeUint64(KeySQLText)
157-
return enc.EncodeString(expr)
158-
}
159-
160-
func fillUnprepare(enc *msgpack.Encoder, stmt Prepared) error {
161-
enc.EncodeMapLen(1)
162-
enc.EncodeUint64(KeyStmtID)
163-
return enc.EncodeUint64(uint64(stmt.StatementID))
164-
}
165-
166-
func fillExecutePrepared(enc *msgpack.Encoder, stmt Prepared, args interface{}) error {
167-
enc.EncodeMapLen(2)
168-
enc.EncodeUint64(KeyStmtID)
169-
enc.EncodeUint64(uint64(stmt.StatementID))
170-
enc.EncodeUint64(KeySQLBind)
171-
return encodeSQLBind(enc, args)
172-
}

0 commit comments

Comments
 (0)