-
Notifications
You must be signed in to change notification settings - Fork 34
fix #201: separate config #205
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
base: master
Are you sure you want to change the base?
Conversation
gofmt demands horizontal alignment? That's... insane. |
defaultConfigPath := filepath.Join(userConfigDir, "go-librespot", "config.yaml") | ||
f.StringVar(&cfg.ConfigPath, "config", defaultConfigPath, "the configuration file") | ||
|
||
userCacheDir, err := os.UserCacheDir() |
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 think this should be XDG_STATE_HOME
rather than XDG_CACHE_HOME
. Eventually there'll be proper cache too.
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.
That would be ideal, yes, but os
pkg does not yet support it.
// backwards compatibility for config_dir flag | ||
func aliasNormalizeFunc(f *flag.FlagSet, name string) flag.NormalizedName { | ||
switch name { | ||
case "config_dir": | ||
name = "cache" | ||
break | ||
} | ||
return flag.NormalizedName(name) | ||
} |
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 think it would be clearer to explictely keep the config_dir
option, for backward compatibility.
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 I keep it should it follow UserConfigDir or UserCacheDir semantics?
If the former then we have a breaking change for existing deployments of go-librespot.
Either way I take your point - I'll find a way to make it more explicit.
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.
Making use of pflag.MarkDeprecated
? (And then unhiding the flag, because pflag autohides it)
$ go run ./cmd/daemon -help
--cache string the cache directory (default "/var/cache/go-librespot")
--config string the configuration file (default "/etc/go-librespot/config.yaml")
--config_dir string old config directory (default "/var/cache/go-librespot") (DEPRECATED: has been renamed --cache)
It doesn't improve things, IMO.
Given go-librespot is pre v1.0 I'd much rather see config_dir
dropped with prejudice. Not having underscores in flags is an added bonus.
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.
@guidcruncher, your view?
Default state dir moves from os.UserConfigDir to os.UserCacheDir
3f0db8a
to
2527809
Compare
Im all for standards. I agree with the parameter naming too.. yeah I like.
configuration in /etc unless overridden etc etc..
…On Mon, 15 Sept 2025, 18:21 markferry, ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In cmd/daemon/main.go
<#205 (comment)>
:
> +// backwards compatibility for config_dir flag
+func aliasNormalizeFunc(f *flag.FlagSet, name string) flag.NormalizedName {
+ switch name {
+ case "config_dir":
+ name = "cache"
+ break
+ }
+ return flag.NormalizedName(name)
+}
@guidcruncher <https://github.com/guidcruncher>, your view?
—
Reply to this email directly, view it on GitHub
<#205 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BLPK5EFKE24YQSF6NRZB7Q33S3YRXAVCNFSM6AAAAACGIMEOPGVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZTEMRVGYYTCNZVGQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Fixes #201
This moves state files from
os.UserConfigDir
toos.UserCacheDir
by default.The config file remains in the original location.
add --config flag
os.UserConfigDir()
add --cache flag
config_dir
flag tocache
os.UserCacheDir()
config_dir
To use the old behaviour:
go run ./cmd/daemon --cache $XDG_CONFIG_HOME/go-librespot