Skip to content

Add crossplatform home directory detection #542

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

felixhudson
Copy link

I have noticed that the global config is not being used on windows. Here is my attempt to fix it.

Copy link

This pull request has been automatically marked as stale because it has not had recent activity.

@github-actions github-actions bot added the stale No recent activity label May 31, 2025
@felixhudson felixhudson mentioned this pull request Jun 16, 2025
2 tasks
@tjex
Copy link
Member

tjex commented Jun 22, 2025

Makes sense, but you shouldn't need to create an err variable?
The method returns an error. https://pkg.go.dev/os#UserHomeDir

@tjex tjex removed the stale No recent activity label Jun 22, 2025
@felixhudson
Copy link
Author

Yeah its odd having creating the error variable, but without it the compiler complains that err doesnt exist. Or with the := method it claims I can't override the home variable from the parent scope.

An alternative is to have home2, err := os.UserHomeDir() , then have an extra if statement to compare home with home2 and create a path with the correct one. But I thought that is just introducing an extra variable for no reason, and adds extra complexity.

I found this solution to be the most concise.

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.

2 participants