internal: check error before deferring file Close()

If there is an error, file will be `nil`. We should check the returned error before deferring file `Close()`.
This commit is contained in:
Emil Hessman
2017-08-13 19:07:23 +02:00
parent a0966e1d1d
commit c2ff7150aa
3 changed files with 3 additions and 4 deletions

View File

@@ -94,8 +94,8 @@ func Random(seed, count int) []byte {
// SetupTarTestFixture extracts the tarFile to outputDir.
func SetupTarTestFixture(t testing.TB, outputDir, tarFile string) {
input, err := os.Open(tarFile)
defer input.Close()
OK(t, err)
defer input.Close()
var rd io.Reader
switch filepath.Ext(tarFile) {