@@ -102,9 +102,63 @@ type Walk struct {
102102 root * Path
103103}
104104
105+ type WalkOptsFunc func (config * WalkOpts )
106+
107+ func WalkDepth (depth int ) WalkOptsFunc {
108+ return func (config * WalkOpts ) {
109+ config .Depth = depth
110+ }
111+ }
112+
113+ func WalkAlgorithm (algo Algorithm ) WalkOptsFunc {
114+ return func (config * WalkOpts ) {
115+ config .Algorithm = algo
116+ }
117+ }
118+
119+ func WalkFollowSymlinks (follow bool ) WalkOptsFunc {
120+ return func (config * WalkOpts ) {
121+ config .FollowSymlinks = follow
122+ }
123+ }
124+
125+ func WalkMinimumFileSize (size int64 ) WalkOptsFunc {
126+ return func (config * WalkOpts ) {
127+ config .MinimumFileSize = size
128+ }
129+ }
130+
131+ func WalkMaximumFileSize (size int64 ) WalkOptsFunc {
132+ return func (config * WalkOpts ) {
133+ config .MaximumFileSize = size
134+ }
135+ }
136+
137+ func WalkVisitFiles (value bool ) WalkOptsFunc {
138+ return func (config * WalkOpts ) {
139+ config .VisitFiles = value
140+ }
141+ }
142+
143+ func WalkVisitDirs (value bool ) WalkOptsFunc {
144+ return func (config * WalkOpts ) {
145+ config .VisitDirs = value
146+ }
147+ }
148+
149+ func WalkVisitSymlinks (value bool ) WalkOptsFunc {
150+ return func (config * WalkOpts ) {
151+ config .VisitSymlinks = value
152+ }
153+ }
154+
105155// NewWalk returns a new Walk struct with default values applied
106- func NewWalk (root * Path ) (* Walk , error ) {
107- return NewWalkWithOpts (root , DefaultWalkOpts ())
156+ func NewWalk (root * Path , opts ... WalkOptsFunc ) (* Walk , error ) {
157+ config := DefaultWalkOpts ()
158+ for _ , opt := range opts {
159+ opt (config )
160+ }
161+ return NewWalkWithOpts (root , config )
108162}
109163
110164// NewWalkWithOpts returns a Walk object with the given WalkOpts applied
0 commit comments