Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork125
feat: prefer os specific config dirs#616
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
tucksaun left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thank you for starting the work on this
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
| home,err:=os.UserHomeDir() | ||
| iferr!=nil { | ||
| home="." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Given my last comment it would be "covered"/"used" as the latest fallback so I would not use it here (inverting the condition and use the legacy only if present)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I don't understand. "home" here is just a fallback in case anything goes wrong with the detection?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
... a more proper way would be to use os.Getwd() I guess
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
my point is that we have to handle a global fallback case if everything fails.
this is the. case.
because we will handle it as a last resort anyway, we don't have to deal with it here, which allows for early returns without variables leaking or inaccurate naming (the naming is inaccurate in the lastreturn legacy in the sense it is a fallback not necessarily a legacy path). eg, something as:
// use the old path if it exists alreadyifhome,err:=os.UserHomeDir();err==nil {legacyPath:=filepath.Join(home,"."+confDir)if_,err:=os.Stat(legacyPath);!os.IsNotExist(err) {returnlegacyPath}}
tjblackheartMay 20, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I see, thanks for the explanation. "home" at this point was the base for the following legacy folder check and also the check for a macos~/.config. I guess if we remove the macos stuff this can go too.
If we include this like your proposal though, legacyPath will be needed again in the last return.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Hey@tucksaun, you think we can finish up this little thing? If these mere 10 lines of code are somehow not up to your standard please say so and I just close it, no problem. If not, I don't see whats the hold up. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
If we include this like your proposal though, legacyPath will be needed again in the last return.
No because the last return (acting as a fallback) would then bereturn "./." + confDir.
Overall this organisation is mostly nice for us maintainers because it means theif block handling the legacy path is only responsible for handling legacy, not the fallback:
- we can have a warning about the use of the legacy path and the need to migrate
- we only have to remove this block when we remove support for legacy config directories
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
No because the last return (acting as a fallback) would then be return "./." + confDir.
Which is exactly whatlegacyPath is set to beforehand in any case. But sure, i've changed it to a hardcoded path.
Uh oh!
There was an error while loading.Please reload this page.
Closes#133