From 6441e98f62a87d336fda3f6a1fd7505f9426a0ab Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Fri, 2 Feb 2018 19:28:09 +1100 Subject: [PATCH] Implement go vet recommendations --- reader_test.go | 3 ++- storage/mmap.go | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/reader_test.go b/reader_test.go index 1cb0c4fd..86021dd6 100644 --- a/reader_test.go +++ b/reader_test.go @@ -17,7 +17,8 @@ func TestReaderReadContext(t *testing.T) { tt, err := cl.AddTorrent(testutil.GreetingMetaInfo()) require.NoError(t, err) defer tt.Drop() - ctx, _ := context.WithDeadline(context.Background(), time.Now().Add(time.Millisecond)) + ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(time.Millisecond)) + defer cancel() r := tt.Files()[0].NewReader() defer r.Close() _, err = r.ReadContext(ctx, make([]byte, 1)) diff --git a/storage/mmap.go b/storage/mmap.go index d859c2e5..8bce4dc7 100644 --- a/storage/mmap.go +++ b/storage/mmap.go @@ -46,7 +46,7 @@ func (s *mmapClientImpl) Close() error { type mmapTorrentStorage struct { infoHash metainfo.Hash - span mmap_span.MMapSpan + span *mmap_span.MMapSpan pc PieceCompletion } @@ -55,8 +55,8 @@ func (ts *mmapTorrentStorage) Piece(p metainfo.Piece) PieceImpl { pc: ts.pc, p: p, ih: ts.infoHash, - ReaderAt: io.NewSectionReader(&ts.span, p.Offset(), p.Length()), - WriterAt: missinggo.NewSectionWriter(&ts.span, p.Offset(), p.Length()), + ReaderAt: io.NewSectionReader(ts.span, p.Offset(), p.Length()), + WriterAt: missinggo.NewSectionWriter(ts.span, p.Offset(), p.Length()), } } @@ -92,7 +92,8 @@ func (sp mmapStoragePiece) MarkNotComplete() error { return nil } -func mMapTorrent(md *metainfo.Info, location string) (mms mmap_span.MMapSpan, err error) { +func mMapTorrent(md *metainfo.Info, location string) (mms *mmap_span.MMapSpan, err error) { + mms = &mmap_span.MMapSpan{} defer func() { if err != nil { mms.Close()