-
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'simplesurance-fail_on_io_errors'
- Loading branch information
Showing
7 changed files
with
326 additions
and
278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package doublestar | ||
|
||
// glob is an internal type to store options during globbing. | ||
type glob struct { | ||
failOnIOErrors bool | ||
} | ||
|
||
// GlobOption represents a setting that can be passed to Glob, GlobWalk, and | ||
// FilepathGlob. | ||
type GlobOption func(*glob) | ||
|
||
// Construct a new glob object with the given options | ||
func newGlob(opts ...GlobOption) *glob { | ||
g := &glob{} | ||
for _, opt := range opts { | ||
opt(g) | ||
} | ||
return g | ||
} | ||
|
||
// WithFailOnIOErrors is an option that can be passed to Glob, GlobWalk, or | ||
// FilepathGlob. If passed, it enables aborting and returning the error when an | ||
// IO error is encountered. | ||
// | ||
func WithFailOnIOErrors() GlobOption { | ||
return func(g *glob) { | ||
g.failOnIOErrors = true | ||
} | ||
} | ||
|
||
// forwardErrIfFailOnIOErrors is used to wrap the return values of I/O | ||
// functions. When failOnIOErrors is enabled, it will return err; otherwise, it | ||
// always returns nil. | ||
func (g *glob) forwardErrIfFailOnIOErrors(err error) error { | ||
if g.failOnIOErrors { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
func (g *glob) GoString() string { | ||
if g.failOnIOErrors { | ||
return "opts: WithFailOnIOErrors" | ||
} | ||
return "opts: nil" | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters