Skip to content

Commit

Permalink
Fix error handling in build.go copyFile()
Browse files Browse the repository at this point in the history
  • Loading branch information
zcalusic committed Feb 18, 2018
1 parent 668c992 commit c3b57a1
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions build.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ func copyFile(dst, src string) error {
}

if err = os.MkdirAll(filepath.Dir(dst), 0755); err != nil {
fmt.Printf("MkdirAll(%v)\n", filepath.Dir(dst))
return err
}

Expand All @@ -186,23 +185,19 @@ func copyFile(dst, src string) error {
return err
}

if err == nil {
err = fsrc.Close()
}

if err == nil {
err = fdst.Close()
if err = fsrc.Close(); err != nil {
return err
}

if err == nil {
err = os.Chmod(dst, fi.Mode())
if err = fdst.Close(); err != nil {
return err
}

if err == nil {
err = os.Chtimes(dst, fi.ModTime(), fi.ModTime())
if err = os.Chmod(dst, fi.Mode()); err != nil {
return err
}

return nil
return os.Chtimes(dst, fi.ModTime(), fi.ModTime())
}

// die prints the message with fmt.Fprintf() to stderr and exits with an error
Expand Down

0 comments on commit c3b57a1

Please sign in to comment.