diff --git a/io.go b/io.go index ac2cf71..cb56559 100644 --- a/io.go +++ b/io.go @@ -7,7 +7,10 @@ import ( "net" "os" "strconv" - "syscall" +) + +var ( + ErrAgain = errors.New("operation not performed") ) type Client struct { @@ -62,7 +65,7 @@ func Raw[T any](d *Client, opcode uint32, payload any) (uint32, T, error) { // Raw writes a raw payload to Discord and returns the response opcode and payload func (d *Client) Raw(opcode uint32, payload any) (uint32, []byte, error) { opcodeResp, payloadResp, err := d.raw(opcode, payload) - if errors.Is(err, syscall.EPIPE) { + if errors.Is(err, errPipe) { // clean up as much as possible _ = d.Close() // advise retry diff --git a/io_unix.go b/io_unix.go index 32d3284..8043392 100644 --- a/io_unix.go +++ b/io_unix.go @@ -1,15 +1,16 @@ +//go:build !windows + package rpcfetch import ( "errors" "io/fs" "net" + "syscall" "time" ) -var ( - ErrAgain = errors.New("operation not performed") -) +var errPipe = syscall.EPIPE func (d *Client) dial() error { if d.dialed {