package config import ( "fmt" "os" "path/filepath" "github.com/BurntSushi/toml" ) type Config struct { APIKey string `toml:"api_key"` } func LoadConfig() (*Config, error) { homeDir, err := os.UserHomeDir() if err != nil { return nil, fmt.Errorf("could not determine home directory: %w", err) } configPath := filepath.Join(homeDir, ".config", "ytgo", "config.toml") var config Config if _, err := toml.DecodeFile(configPath, &config); err != nil { return nil, fmt.Errorf("could not read config file: %w", err) } if config.APIKey == "" { return nil, fmt.Errorf("API key is missing in config file") } return &config, nil }