Skip to content

feat(options): Add cmdline option to not follow symlinks#127

Merged
svent merged 3 commits into
svent:masterfrom
yermulnik:master
Jun 30, 2026
Merged

feat(options): Add cmdline option to not follow symlinks#127
svent merged 3 commits into
svent:masterfrom
yermulnik:master

Conversation

@yermulnik

@yermulnik yermulnik commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Resolves #113

Add NoFollowSymlinks (--no-follow) option.


Also while here lint and format code (gopls, go vet, gofmt):

  • options.go:

    • ioutil.ReadFile is deprecated: As of Go 1.16, this function simply calls [os.ReadFile]
    • ioutil.WriteFile is deprecated: As of Go 1.16, this function simply calls [os.WriteFile]
    • ioutil.Discard is deprecated: As of Go 1.16, this value is simply [io.Discard]
    • "golang.org/x/crypto/ssh/terminal" is deprecated: Deprecated: this package moved to golang.org/x/term.
  • sift.go:

    • "golang.org/x/crypto/ssh/terminal" is deprecated: Deprecated: this package moved to golang.org/x/term.
  • sift.go:

    • should check error returned from os.Open() before deferring f.Close()
    • unnecessary nil check around range
    • if statement can be modernized using min
    • bufio.Scanner "scanner" is used in Scan loop at line 623 without final check of scanner.Err()
  • matching.go:

    • if statement can be modernized using min
    • for loop can be modernized using range over int
    • bufio.Scanner "scanner" is used in Scan loop at line 610 without final check of scanner.Err()

yermulnik added 2 commits June 3, 2026 18:57
Add `NoFollowSymlinks` (`--no-follow`) option.

While here do `gofmt` in `options.go` file.
`options.go`:
* `ioutil.ReadFile is deprecated: As of Go 1.16, this function simply calls [os.ReadFile]`
* `ioutil.WriteFile is deprecated: As of Go 1.16, this function simply calls [os.WriteFile]`
* `ioutil.Discard is deprecated: As of Go 1.16, this value is simply [io.Discard]`
* `"golang.org/x/crypto/ssh/terminal" is deprecated: Deprecated: this package moved to golang.org/x/term.`

`sift.go`:
* `"golang.org/x/crypto/ssh/terminal" is deprecated: Deprecated: this package moved to golang.org/x/term.`

`sift.go`:
* `should check error returned from os.Open() before deferring f.Close()`
* `unnecessary nil check around range`
* `if statement can be modernized using min`
* `bufio.Scanner "scanner" is used in Scan loop at line 623 without final check of scanner.Err()`

`matching.go`:
* `if statement can be modernized using min`
* `for loop can be modernized using range over int`
* `bufio.Scanner "scanner" is used in Scan loop at line 610 without final check of scanner.Err()`
Copilot AI review requested due to automatic review settings June 3, 2026 16:35
@yermulnik yermulnik changed the title feat(options): Add cmdline option to do not follow symlinks feat(options): Add cmdline option to not follow symlinks Jun 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Modernizes the codebase to use current Go APIs and small refactors, while improving robustness in file/scan handling.

Changes:

  • Replace deprecated ioutil and x/crypto/ssh/terminal usage with os/io and golang.org/x/term.
  • Simplify slice/range logic (min/max, slicing, composite literals) and add missing scanner.Err() checks.
  • Add a //go:build constraint and introduce --no-follow flag handling.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
sift.go Uses x/term, simplifies slicing/loops, and adds scanner error handling for pattern files
output.go Small cleanup of variable declaration and slice expressions for readability
options.go Replaces deprecated ioutil, switches to x/term, and adds --no-follow option handler
matching_other.go Adds //go:build line to align with modern Go build constraints
matching.go Simplifies logic and literals, adds scanner error handling, but introduces a compile-time loop issue

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread matching.go
Comment thread matching.go Outdated
Comment thread sift.go
@yermulnik

Copy link
Copy Markdown
Contributor Author

@svent Will you have a moment to look at this PR please? 🙏🏻

@yermulnik

Copy link
Copy Markdown
Contributor Author

Friendly reminder.

@yermulnik

Copy link
Copy Markdown
Contributor Author

Another friendly nudge 🙏🏻

@yermulnik

Copy link
Copy Markdown
Contributor Author

Just another friendly ping.

@svent

svent commented Jun 30, 2026

Copy link
Copy Markdown
Owner

Thanks for your contribution, looks good to me!

@svent svent merged commit 76db109 into svent:master Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Command line option to NOT follow symlinks

3 participants