Skip to content

Commit

Permalink
Make sure you close files after opening them.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwilkie committed Mar 12, 2017
1 parent 072e002 commit dfef622
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion analysis.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,15 @@ func ListPackages(fileRoot, importRoot string) (PackageTree, error) {
// would have an err with the same path as is called this time, as only
// then will filepath.Walk have attempted to descend into the directory
// and encountered an error.
_, err = os.Open(wp)
var f *os.File
f, err = os.Open(wp)
if err != nil {
if os.IsPermission(err) {
return filepath.SkipDir
}
return err
}
defer f.Close()

// Compute the import path. Run the result through ToSlash(), so that
// windows file paths are normalized to slashes, as is expected of
Expand Down

0 comments on commit dfef622

Please sign in to comment.