Skip to content

Commit 1198293

Browse files
myitcvflimzy
authored andcommitted
Fix file closing
1 parent 2109552 commit 1198293

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

build/build.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,10 +606,10 @@ func (s *Session) BuildPackage(pkg *PackageData) (*compiler.Archive, error) {
606606
if err != nil {
607607
return nil, fmt.Errorf("could not open %v: %v", binPath, err)
608608
}
609-
defer binFile.Close()
610609

611610
binHash := sha256.New()
612611
io.Copy(binHash, binFile)
612+
binFile.Close()
613613
fmt.Fprintf(pkgHash, "gopherjs bin: %#x\n", binHash.Sum(nil))
614614

615615
orderedBuildTags := append([]string{}, s.options.BuildTags...)
@@ -654,6 +654,7 @@ func (s *Session) BuildPackage(pkg *PackageData) (*compiler.Archive, error) {
654654
}
655655
fmt.Fprintf(pkgHash, "file: %v\n", fp)
656656
n, _ := io.Copy(pkgHash, file)
657+
file.Close()
657658
fmt.Fprintf(pkgHash, "%d bytes\n", n)
658659
}
659660

@@ -669,9 +670,9 @@ func (s *Session) BuildPackage(pkg *PackageData) (*compiler.Archive, error) {
669670
}
670671
return nil, err
671672
}
672-
defer objFile.Close()
673673

674674
archive, err := compiler.ReadArchive(pkg.PkgObj, pkg.ImportPath, objFile, s.Types)
675+
objFile.Close()
675676
if err != nil {
676677
return nil, err
677678
}

0 commit comments

Comments
 (0)