fixed struct alignment && refactor linter (#369)
All checks were successful
test / test (push) Successful in 42s

## Pull Request template
Please, go through these steps before clicking submit on this PR.

1. Give a descriptive title to your PR.
2. Provide a description of your changes.
3. Make sure you have some relevant tests.
4. Put `closes #XXXX` in your comment to auto-close the issue that your PR fixes (if applicable).

**PLEASE REMOVE THIS TEMPLATE BEFORE SUBMITTING**

Reviewed-on: #369
Co-authored-by: Evstigneev Denis <danteevstigneev@yandex.ru>
Co-committed-by: Evstigneev Denis <danteevstigneev@yandex.ru>
This commit is contained in:
2024-12-09 16:23:25 +03:00
parent b6a0e4d983
commit 38c5fe8b5a
67 changed files with 480 additions and 398 deletions

View File

@@ -11,12 +11,15 @@ import (
)
type dnsConn struct {
deadline time.Time
ctx context.Context
cancel context.CancelFunc
roundTrip roundTripper
ibuf bytes.Buffer
obuf bytes.Buffer
deadline time.Time
ibuf bytes.Buffer
obuf bytes.Buffer
sync.Mutex
}
@@ -81,7 +84,7 @@ func (c *dnsConn) SetReadDeadline(t time.Time) error {
return nil
}
func (c *dnsConn) SetWriteDeadline(t time.Time) error {
func (c *dnsConn) SetWriteDeadline(_ time.Time) error {
// writes do not timeout
return nil
}
@@ -159,23 +162,22 @@ func readMessage(c net.Conn) (string, error) {
return "", err
}
return string(b[:n]), nil
} else {
var sz [2]byte
_, err := io.ReadFull(c, sz[:])
if err != nil {
return "", err
}
size := int64(sz[0])<<8 | int64(sz[1])
var str strings.Builder
_, err = io.CopyN(&str, c, size)
if err == io.EOF {
return "", io.ErrUnexpectedEOF
}
if err != nil {
return "", err
}
return str.String(), nil
}
var sz [2]byte
_, err := io.ReadFull(c, sz[:])
if err != nil {
return "", err
}
size := int64(sz[0])<<8 | int64(sz[1])
var str strings.Builder
_, err = io.CopyN(&str, c, size)
if err == io.EOF {
return "", io.ErrUnexpectedEOF
}
if err != nil {
return "", err
}
return str.String(), nil
}