From: Matt Joiner Date: Sat, 6 Jan 2018 05:53:40 +0000 (+1100) Subject: megacheck and staticcheck fixes X-Git-Tag: v1.0.0~297 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=2f616b9d8b46ba4f8a56eaad159399743c842fef;p=btrtrc.git megacheck and staticcheck fixes --- diff --git a/cmd/torrentfs/main.go b/cmd/torrentfs/main.go index 1d12d6a7..ed3d94bf 100644 --- a/cmd/torrentfs/main.go +++ b/cmd/torrentfs/main.go @@ -48,7 +48,7 @@ var ( ) func exitSignalHandlers(fs *torrentfs.TorrentFS) { - c := make(chan os.Signal) + c := make(chan os.Signal, 1) signal.Notify(c, syscall.SIGINT, syscall.SIGTERM) for { <-c diff --git a/tracker/udp_test.go b/tracker/udp_test.go index 61ff8c58..3330cba3 100644 --- a/tracker/udp_test.go +++ b/tracker/udp_test.go @@ -48,10 +48,8 @@ func TestMarshalAnnounceResponse(t *testing.T) { func TestLongWriteUDP(t *testing.T) { t.Parallel() l, err := net.ListenUDP("udp4", nil) + require.NoError(t, err) defer l.Close() - if err != nil { - t.Fatal(err) - } c, err := net.DialUDP("udp", nil, l.LocalAddr().(*net.UDPAddr)) if err != nil { t.Fatal(err) diff --git a/util/dirwatch/dirwatch_test.go b/util/dirwatch/dirwatch_test.go index 40d68ff7..220f58b5 100644 --- a/util/dirwatch/dirwatch_test.go +++ b/util/dirwatch/dirwatch_test.go @@ -4,6 +4,8 @@ import ( "io/ioutil" "os" "testing" + + "github.com/stretchr/testify/require" ) func TestDirwatch(t *testing.T) { @@ -14,8 +16,6 @@ func TestDirwatch(t *testing.T) { defer os.RemoveAll(tempDirName) t.Logf("tempdir: %q", tempDirName) dw, err := New(tempDirName) + require.NoError(t, err) defer dw.Close() - if err != nil { - t.Fatal(err) - } }