MCPcopy Create free account
hub / github.com/capable-average/tagTonic / LoadConfig

Function LoadConfig

config/config.go:50–76  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

48}
49
50func LoadConfig() (*Config, error) {
51 config := DefaultConfig()
52
53 home, err := homedir.Dir()
54 if err != nil {
55 return nil, fmt.Errorf("failed to find home directory: %w", err)
56 }
57
58 configDir := filepath.Join(home, ".config", "tagTonic")
59 viper.AddConfigPath(configDir)
60 viper.AddConfigPath(home)
61 viper.AddConfigPath(".")
62 viper.SetConfigName("config")
63 viper.SetConfigType("yaml")
64
65 viper.SetConfigName("config")
66
67 viper.AutomaticEnv()
68
69 if err := viper.ReadInConfig(); err == nil {
70 if err := viper.Unmarshal(config); err != nil {
71 return nil, fmt.Errorf("failed to unmarshal config: %w", err)
72 }
73 }
74
75 return config, nil
76}
77
78func SaveConfig(config *Config) error {
79 home, err := homedir.Dir()

Callers 4

NewLyricsPanelFunction · 0.92
RunFunction · 0.92
fetch.goFile · 0.92
processBatchConcurrentlyFunction · 0.92

Calls 1

DefaultConfigFunction · 0.85

Tested by

no test coverage detected