Skip to content

Commit

Permalink
Back out of requiring a Closer for every Conn
Browse files Browse the repository at this point in the history
  • Loading branch information
belak committed May 29, 2020
1 parent 232fce1 commit 125cf61
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 24 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ jobs:
- name: Clean up extra files
run: rm ./testcases/*.go

- name: Run golangci-lint
uses: actions-contrib/golangci-lint@v1
env:
GOROOT: ''
with:
golangci_lint_version: 'v1.27.0'
# This is disabled until is properly respects the golangci_lint_version
#- name: Run golangci-lint
# uses: actions-contrib/golangci-lint@v1
# env:
# GOROOT: ''
# with:
# golangci_lint_version: 'v1.27.0'

- name: Download deps
run: go mod download
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ just using this library, these are not needed.
### v4 - Under Development

- Move client to the new ircx package
- Add Conn.Close

### v3

Expand Down
14 changes: 3 additions & 11 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,13 @@ import (
type Conn struct {
*Reader
*Writer

rwc io.ReadWriteCloser
}

// NewConn creates a new Conn.
func NewConn(rwc io.ReadWriteCloser) *Conn {
func NewConn(rw io.ReadWriter) *Conn {
return &Conn{
NewReader(rwc),
NewWriter(rwc),
rwc,
NewReader(rw),
NewWriter(rw),
}
}

Expand Down Expand Up @@ -117,8 +114,3 @@ func (r *Reader) ReadMessage() (*Message, error) {
// Parse the message from our line
return ParseMessage(line)
}

// Close will close the underlying TCP connection.
func (c *Conn) Close() error {
return c.rwc.Close()
}
6 changes: 0 additions & 6 deletions conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ func (ew *errorWriter) Write([]byte) (int, error) {
type readWriteCloser struct {
io.Reader
io.Writer
io.Closer
}

type testReadWriteCloser struct {
Expand All @@ -44,10 +43,6 @@ func (t *testReadWriteCloser) Write(p []byte) (int, error) {
return t.client.Write(p)
}

func (t *testReadWriteCloser) Close() error {
return nil
}

func testReadMessage(t *testing.T, c *Conn) *Message {
m, err := c.ReadMessage()
assert.NoError(t, err)
Expand Down Expand Up @@ -79,7 +74,6 @@ func TestWriteMessageError(t *testing.T) {
rw := &readWriteCloser{
&bytes.Buffer{},
&errorWriter{},
nil,
}

c := NewConn(rw)
Expand Down

0 comments on commit 125cf61

Please sign in to comment.