Files
dpurbosakti 918bbaa315 update logo
2025-12-17 15:11:32 +07:00

49 lines
907 B
Go

package assets
import (
"log"
"os"
"path/filepath"
)
func exeDir() string {
exe, err := os.Executable()
if err != nil {
panic(err)
}
return filepath.Dir(exe)
}
func GetAssetsDir() string {
exe, err := os.Executable()
if err != nil {
log.Println(
"[ASSETS][ERROR] Failed to resolve executable path.",
"This should never happen in a built binary.",
"Error:", err,
)
return ""
}
exeDir := filepath.Dir(exe)
assets := filepath.Join(exeDir, "assets")
if _, err := os.Stat(assets); err != nil {
log.Println(
"[ASSETS][ERROR] Assets directory not found next to binary.",
"This error ONLY occurs when the application is running from a built binary.",
"Expected path:", assets,
"Executable path:", exe,
)
return ""
}
log.Println(
"[ASSETS][OK] Static assets enabled.",
"Mode: production (binary execution).",
"Assets path:", assets,
)
return assets
}