package static import ( "embed" "io/fs" "log" "os" "path/filepath" ) //go:embed build var embeddedBuild embed.FS func BuildFS() fs.FS { sub, err := fs.Sub(embeddedBuild, "build") if err != nil { log.Printf("[static] embed nao disponivel, tentando filesystem: %v", err) // Fallback: look for build directory relative to the backend binary dir := os.Getenv("YAUM_STATIC_DIR") if dir == "" { // Try common locations candidates := []string{ "../frontend/build", "frontend/build", "./build", } for _, c := range candidates { if info, e := os.Stat(c); e == nil && info.IsDir() { dir = c break } } } if dir != "" { abs, _ := filepath.Abs(dir) log.Printf("[static] servindo de %s", abs) return os.DirFS(dir) } return nil } log.Println("[static] servindo de embed") return sub }