diff options
author | Valentin Popov <valentin@popov.link> | 2025-06-04 12:09:26 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-04 12:09:26 +0300 |
commit | b57c1a6878190abd6ed63e285e13b03a4fbac7a3 (patch) | |
tree | 32d143bd87bfb182c2035c6be09c6ee3b035f903 /internal/conn/conn.go | |
parent | 7240595478fedec02e9e47c704976cf56a66d3e8 (diff) | |
download | go-metatrader4-b57c1a6878190abd6ed63e285e13b03a4fbac7a3.tar.xz go-metatrader4-b57c1a6878190abd6ed63e285e13b03a4fbac7a3.zip |
Added GitHub Actions (#4)
Diffstat (limited to 'internal/conn/conn.go')
-rw-r--r-- | internal/conn/conn.go | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/internal/conn/conn.go b/internal/conn/conn.go index a1da6f1..0bf3ae6 100644 --- a/internal/conn/conn.go +++ b/internal/conn/conn.go @@ -32,9 +32,13 @@ func (c *Conn) Close() error { func (c *Conn) Send(ctx context.Context, data []byte, timeout time.Duration) error { if dl, ok := ctx.Deadline(); ok { - c.netConn.SetWriteDeadline(dl) + if err := c.netConn.SetWriteDeadline(dl); err != nil { + return err + } } else { - c.netConn.SetWriteDeadline(time.Now().Add(timeout)) + if err := c.netConn.SetWriteDeadline(time.Now().Add(timeout)); err != nil { + return err + } } _, err := c.netConn.Write(data) return err @@ -42,9 +46,13 @@ func (c *Conn) Send(ctx context.Context, data []byte, timeout time.Duration) err func (c *Conn) Receive(ctx context.Context, timeout time.Duration) ([]byte, error) { if dl, ok := ctx.Deadline(); ok { - c.netConn.SetReadDeadline(dl) + if err := c.netConn.SetReadDeadline(dl); err != nil { + return nil, err + } } else { - c.netConn.SetReadDeadline(time.Now().Add(timeout)) + if err := c.netConn.SetReadDeadline(time.Now().Add(timeout)); err != nil { + return nil, err + } } return io.ReadAll(c.netConn) } |