From 8a901413a8b0bc790e95d15619467ea232678cc8 Mon Sep 17 00:00:00 2001 From: edwargix Date: Sat, 1 Oct 2022 20:44:54 -0400 Subject: [PATCH] Make tiny variable optimization --- config.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/config.go b/config.go index fb02292..519bd93 100644 --- a/config.go +++ b/config.go @@ -19,16 +19,11 @@ func getConfigDir(n string) string { // Find config directory // Linux (XDG base directory specification compliant) - xdg_config_home := os.Getenv("XDG_CONFIG_HOME") - - var base string - if xdg_config_home != "" { - base = xdg_config_home - } else { - home := os.Getenv("HOME") - base = filepath.Join(home, ".config") + if xdg_config_home := os.Getenv("XDG_CONFIG_HOME"); xdg_config_home != "" { + return filepath.Join(xdg_config_home, n) } - return filepath.Join(base, n) + + return filepath.Join(os.Getenv("HOME"), ".config", n) } func (c *Config[T]) Get() (bool, error) {