diff --git a/archiver_test.go b/archiver_test.go index 2699593d..ea8b871d 100644 --- a/archiver_test.go +++ b/archiver_test.go @@ -3,7 +3,6 @@ package archiver import ( "bytes" "fmt" - "io" "io/ioutil" "os" "path/filepath" @@ -323,7 +322,7 @@ func testArchiveUnarchive(t *testing.T, au archiverUnarchiver) { // Test extracting archive dest := filepath.Join(tmp, "extraction_test_"+auStr) - os.Mkdir(dest, 0755) + _ = os.Mkdir(dest, 0755) err = au.Unarchive(outfile, dest) if err != nil { t.Fatalf("[%s] extracting archive [%s -> %s]: didn't expect an error, but got: %v", auStr, outfile, dest, err) @@ -333,6 +332,7 @@ func testArchiveUnarchive(t *testing.T, au archiverUnarchiver) { symmetricTest(t, auStr, dest, true, true) } +/* // testMatching tests that au can match the format of archiveFile. func testMatching(t *testing.T, au archiverUnarchiver, archiveFile string) { m, ok := au.(Matcher) @@ -358,12 +358,13 @@ func testMatching(t *testing.T, au archiverUnarchiver, archiveFile string) { t.Fatalf("%s (%T): format should have matched, but didn't", m, m) } } +*/ // symmetricTest compares the contents of a destination directory to the contents // of the test corpus and tests that they are equal. func symmetricTest(t *testing.T, formatName, dest string, testSymlinks, testModes bool) { var expectedFileCount int - filepath.Walk("testdata/corpus", func(fpath string, info os.FileInfo, err error) error { + _ = filepath.Walk("testdata/corpus", func(fpath string, info os.FileInfo, err error) error { if testSymlinks || (info.Mode()&os.ModeSymlink) == 0 { expectedFileCount++ } @@ -373,7 +374,7 @@ func symmetricTest(t *testing.T, formatName, dest string, testSymlinks, testMode // If outputs equals inputs, we're good; traverse output files // and compare file names, file contents, and file count. var actualFileCount int - filepath.Walk(dest, func(fpath string, info os.FileInfo, err error) error { + _ = filepath.Walk(dest, func(fpath string, info os.FileInfo, _ error) error { if fpath == dest { return nil } diff --git a/cmd/arc/main.go b/cmd/arc/main.go index dd86bd3e..140255b1 100644 --- a/cmd/arc/main.go +++ b/cmd/arc/main.go @@ -219,7 +219,7 @@ func getFormat(subcommand string) (interface{}, error) { v.ContinueOnError = continueOnError v.Password = os.Getenv("ARCHIVE_PASSWORD") case *archiver.Tar: - v = mytar + f = mytar case *archiver.TarBrotli: v.Tar = mytar v.Quality = compressionLevel diff --git a/rar.go b/rar.go index 84eabda8..8fdf223c 100644 --- a/rar.go +++ b/rar.go @@ -363,7 +363,9 @@ func (*Rar) Match(file io.ReadSeeker) (bool, error) { if err != nil { return false, err } - defer file.Seek(currentPos, io.SeekStart) + defer func() { + _, _ = file.Seek(currentPos, io.SeekStart) + }() buf := make([]byte, 8) if n, err := file.Read(buf); err != nil || n < 8 { diff --git a/sz.go b/sz.go index 39c5865e..02009b52 100644 --- a/sz.go +++ b/sz.go @@ -13,7 +13,7 @@ type Snappy struct{} // Compress reads in, compresses it, and writes it to out. func (s *Snappy) Compress(in io.Reader, out io.Writer) error { - w := snappy.NewWriter(out) + w := snappy.NewBufferedWriter(out) defer w.Close() _, err := io.Copy(w, in) return err diff --git a/tar.go b/tar.go index 6dda50a0..dbac6920 100644 --- a/tar.go +++ b/tar.go @@ -546,7 +546,9 @@ func (*Tar) Match(file io.ReadSeeker) (bool, error) { if err != nil { return false, err } - defer file.Seek(currentPos, io.SeekStart) + defer func() { + _, _ = file.Seek(currentPos, io.SeekStart) + }() buf := make([]byte, tarBlockSize) if _, err = io.ReadFull(file, buf); err != nil { diff --git a/tarsz.go b/tarsz.go index 0569e664..ee3808e6 100644 --- a/tarsz.go +++ b/tarsz.go @@ -77,7 +77,7 @@ func (tsz *TarSz) Extract(source, target, destination string) error { func (tsz *TarSz) wrapWriter() { var sw *snappy.Writer tsz.Tar.writerWrapFn = func(w io.Writer) (io.Writer, error) { - sw = snappy.NewWriter(w) + sw = snappy.NewBufferedWriter(w) return sw, nil } tsz.Tar.cleanupWrapFn = func() { diff --git a/zip.go b/zip.go index 416fdac9..0fa08b7d 100644 --- a/zip.go +++ b/zip.go @@ -76,11 +76,11 @@ type Zip struct { ContinueOnError bool // Compression algorithm - FileMethod ZipCompressionMethod - zw *zip.Writer - zr *zip.Reader - ridx int - decinitialized bool + FileMethod ZipCompressionMethod + zw *zip.Writer + zr *zip.Reader + ridx int + //decinitialized bool } // CheckExt ensures the file extension matches the format. @@ -596,7 +596,9 @@ func (*Zip) Match(file io.ReadSeeker) (bool, error) { if err != nil { return false, err } - defer file.Seek(currentPos, io.SeekStart) + defer func() { + _, _ = file.Seek(currentPos, io.SeekStart) + }() buf := make([]byte, 4) if n, err := file.Read(buf); err != nil || n < 4 {