You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
439 B

  1. package main
  2. import (
  3. "gopkg.in/yaml.v2"
  4. "os"
  5. "path"
  6. )
  7. type Config struct {
  8. Remote string `yaml:"remote"`
  9. }
  10. func loadConfig() (*Config, error) {
  11. homedir, err := os.UserHomeDir()
  12. if err != nil {
  13. return nil, err
  14. }
  15. f, err := os.Open(path.Join(homedir, ".config/lucy.yaml"))
  16. if err != nil {
  17. return nil, err
  18. }
  19. cfg := Config{}
  20. err = yaml.NewDecoder(f).Decode(&cfg)
  21. if err != nil {
  22. return nil, err
  23. }
  24. return &cfg, nil
  25. }