Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8d7d782

Browse files
committed
Remaining lint fixes
1 parent c24774a commit 8d7d782

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

expect/expect_opt.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package expect
1616

1717
import (
1818
"bytes"
19+
"errors"
1920
"io"
2021
"os"
2122
"regexp"
@@ -123,7 +124,7 @@ func (em *errorMatcher) Match(v interface{}) bool {
123124
if !ok {
124125
return false
125126
}
126-
return err == em.err
127+
return errors.Is(err, em.err)
127128
}
128129

129130
func (em *errorMatcher) Criteria() interface{} {

expect/expect_opt_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ package expect_test
1616

1717
import (
1818
"bytes"
19-
"errors"
2019
"io"
2120
"regexp"
2221
"testing"
2322

2423
"github.com/stretchr/testify/require"
24+
"golang.org/x/xerrors"
2525

2626
. "github.com/coder/coder/expect"
2727
)
@@ -258,8 +258,8 @@ func TestExpectOptThen(t *testing.T) {
258258
t.Parallel()
259259

260260
var (
261-
errFirst = errors.New("first")
262-
errSecond = errors.New("second")
261+
errFirst = xerrors.New("first")
262+
errSecond = xerrors.New("second")
263263
)
264264

265265
tests := []struct {

expect/expect_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ func Prompt(in io.Reader, out io.Writer) error {
4949
"What is Netflix backwards?", "xilfteN",
5050
},
5151
} {
52-
53-
_, err := fmt.Fprint(out, fmt.Sprintf("%s: ", survey.Prompt))
52+
_, err := fmt.Fprintf(out, "%s: ", survey.Prompt)
5453
if err != nil {
5554
return err
5655
}

expect/passthrough_pipe.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ func NewPassthroughPipe(reader io.Reader) (*PassthroughPipe, error) {
5353
// If we are unable to close the pipe, and the pipe isn't already closed,
5454
// the caller will hang indefinitely.
5555
panic(err)
56-
return
5756
}
5857

5958
// When an error is read from reader, we need it to passthrough the err to
@@ -91,11 +90,11 @@ func (pp *PassthroughPipe) Close() error {
9190
return pp.reader.Close()
9291
}
9392

94-
func (pp *PassthroughPipe) SetReadDeadline(t time.Time) error {
93+
func (pp *PassthroughPipe) SetReadDeadline(deadline time.Time) error {
9594
// TODO(Bryan): Is there a way to set read deadlines on Windows?
9695
if runtime.GOOS == "windows" {
9796
return nil
98-
} else {
99-
return pp.reader.SetReadDeadline(t)
10097
}
98+
99+
return pp.reader.SetReadDeadline(deadline)
101100
}

0 commit comments

Comments
 (0)