feat: enhance Go module cache setup in CLI

- Added Go module cache directory to the setupDirectories function for improved Go environment configuration.
- Updated cloneAndBuild function to set HOME environment variable, ensuring proper module cache creation during build process.
This commit is contained in:
anonpenguin23 2025-10-31 12:12:27 +02:00
parent 2aead48045
commit c5d3dd1f6d

View File

@ -680,6 +680,7 @@ func setupDirectories() {
"/home/debros/bin",
"/home/debros/src",
"/home/debros/.debros",
"/home/debros/go", // Go module cache directory
}
for _, dir := range dirs {
@ -743,8 +744,10 @@ func cloneAndBuild() {
os.Setenv("PATH", os.Getenv("PATH")+":/usr/local/go/bin")
// Use sudo with --preserve-env=PATH to pass Go path to debros user
// Set HOME so Go knows where to create module cache
cmd := exec.Command("sudo", "--preserve-env=PATH", "-u", "debros", "make", "build")
cmd.Dir = "/home/debros/src"
cmd.Env = append(os.Environ(), "HOME=/home/debros", "PATH="+os.Getenv("PATH")+":/usr/local/go/bin")
if output, err := cmd.CombinedOutput(); err != nil {
fmt.Fprintf(os.Stderr, "❌ Failed to build: %v\n%s\n", err, output)
os.Exit(1)