package main import ( "fmt" "log" "os" "os/exec" "path/filepath" ) type DotfilesConfig struct { Enable bool `mapstructure:"enable"` GitRepo string `mapstructure:"git_repo"` } func setupDotfiles(config DotfilesConfig) error { if _, err := exec.LookPath("git"); err != nil { return fmt.Errorf("git ist nicht installiert") } if _, err := exec.LookPath("stow"); err != nil { return fmt.Errorf("gnu stow ist nicht installiert") } dotfilesDir := filepath.Join(os.Getenv("HOME"), "dotfiles") cmd := exec.Command("git", "clone", config.GitRepo) // cmd := exec.Command("git", "clone", config.GitRepo, dotfilesDir) if err := cmd.Run(); err != nil { return fmt.Errorf("Fehler beim Klonen der Dotfiles: %v", err) } if err := os.Chdir(dotfilesDir); err != nil { return fmt.Errorf("Fehler beim Wechseln in das Dotfiles-Verzeichnis: %v", err) } cmd = exec.Command("stow", ".") if err := cmd.Run(); err != nil { log.Printf("Fehler beim Linken: %v", err) } fmt.Printf("Alles erfolgreich verlinkt\n") return nil }