deps: remove go-homedir in favor of os.UserHomeDir()#2461
Open
deps: remove go-homedir in favor of os.UserHomeDir()#2461
Conversation
Replace github.com/mitchellh/go-homedir with the standard library os.UserHomeDir() which has been available since Go 1.12. This removes a direct dependency from the project (remains as indirect via trivy). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes direct usage of github.com/mitchellh/go-homedir by switching to Go’s standard library os.UserHomeDir(), reducing direct dependency surface while keeping behavior equivalent for home directory resolution.
Changes:
- Replace
homedir.Dir()withos.UserHomeDir()insubcmds/util.go. - Replace
homedir.Dir()withos.UserHomeDir()inscanner/executil.go(SSH control path setup). - Update
go.modto dropgo-homediras a direct dependency (it remains indirect via other deps).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
subcmds/util.go |
Switches home directory lookup to os.UserHomeDir() for .vuls directory creation. |
scanner/executil.go |
Switches home directory lookup to os.UserHomeDir() when constructing SSH ControlPath. |
go.mod |
Removes go-homedir from direct requirements and retains it as an indirect dependency. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why (motivation for removing this dependency)
go-homediris a library for resolving the user's home directory ($HOME/%USERPROFILE%)os.UserHomeDir()(stdlib, Go 1.12+) is a drop-in replacement. The library author recommends using stdlib insteadWhat (replacement details)
homedir.Dir()withos.UserHomeDir()(identical signature:func() (string, error))scanner/executil.go: removedgo-homedirimport, added"os"import, replaced callsubcmds/util.go: removedgo-homedirimport, replaced callSafety (why this is safe)
os.UserHomeDir(). Both resolve the same env vars ($HOME,%USERPROFILE%)Test plan
go build ./cmd/...passgo test ./scanner/...passReview hint (how to review efficiently)
go mod tidyauto-cleanup🤖 Generated with Claude Code