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 committed 2017-08-13 19:28:13 +02:00
1 parent a0966e1d1d
commit c2ff7150aa
3 files changed
+3 -4

No files matched your search

+1 -1
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) {