@@ -625,20 +625,27 @@ func (s *Session) BuildPackage(pkg *PackageData) (*compiler.Archive, error) {
625
625
if pkg .PkgObj != "" {
626
626
fmt .Fprintf (hw , "## %v\n " , pkg .ImportPath )
627
627
628
- binHash := sha256 .New ()
629
- binPath , err := os .Executable ()
630
- if err != nil {
631
- return nil , fmt .Errorf ("could not locate GopherJS binary: %v" , err )
632
- }
633
- binFile , err := os .Open (binPath )
634
- if err != nil {
635
- return nil , fmt .Errorf ("could not open %v: %v" , binPath , err )
628
+ hashBin := func () error {
629
+ binHash := sha256 .New ()
630
+ binPath , err := os .Executable ()
631
+ if err != nil {
632
+ return fmt .Errorf ("could not locate GopherJS binary: %v" , err )
633
+ }
634
+ binFile , err := os .Open (binPath )
635
+ if err != nil {
636
+ return fmt .Errorf ("could not open %v: %v" , binPath , err )
637
+ }
638
+ defer binFile .Close ()
639
+ if _ , err := io .Copy (binHash , binFile ); err != nil {
640
+ return fmt .Errorf ("failed to hash %v: %v" , binPath , err )
641
+ }
642
+ fmt .Fprintf (hw , "gopherjs bin: %#x\n " , binHash .Sum (nil ))
643
+ return nil
636
644
}
637
- defer binFile . Close ()
638
- if _ , err := io . Copy ( binHash , binFile ); err != nil {
639
- return nil , fmt . Errorf ( "failed to hash %v: %v" , binPath , err )
645
+
646
+ if err := hashBin ( ); err != nil {
647
+ return nil , err
640
648
}
641
- fmt .Fprintf (hw , "gopherjs bin: %#x\n " , binHash .Sum (nil ))
642
649
643
650
orderedBuildTags := append ([]string {}, s .options .BuildTags ... )
644
651
sort .Strings (orderedBuildTags )
0 commit comments