You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So I have been trying to run htmx and have this project structure, this does work when all of these three files i.e main.go static_prod.go and static_dev.go is in root of the project alongside embed.go but with below structure it does not work
static_dev.go//go:build dev// +build devpackage main
import (
"fmt""net/http""os"
)
funcpublic() http.Handler {
fmt.Println("Building static files for development")
returnhttp.StripPrefix("../public/**/*", http.FileServerFS(os.DirFS("public")))
}
package main
import (
"context""fmt""log""net/http""os""os/signal""time"
static "github.com/goemon""github.com/goemon/internals/handlers""github.com/joho/godotenv""github.com/labstack/echo/v4""github.com/labstack/echo/v4/middleware"
)
funcmain() {
iferr:=godotenv.Load(); err!=nil {
log.Fatal(err)
}
// Echo instancee:=echo.New()
e.GET("/", func(c echo.Context) error {
time.Sleep(5*time.Second)
returnc.JSON(http.StatusOK, "OK")
})
// Middlewaree.Use(middleware.Logger())
e.Use(middleware.Recover())
// Routese.GET("/*", echo.WrapHandler(http.FileServer(http.FS(static.PublicFS))))
e.GET("/", handlers.Make(handlers.Hello))
// Start serverctx, stop:=signal.NotifyContext(context.Background(), os.Interrupt)
deferstop()
// Start servergofunc() {
iferr:=e.Start(fmt.Sprintf(":%s", os.Getenv("LISTEN_ADDR"))); err!=nil&&err!=http.ErrServerClosed {
e.Logger.Fatal("shutting down the server")
}
}()
// Wait for interrupt signal to gracefully shutdown the server with a timeout of 10 seconds.<-ctx.Done()
ctx, cancel:=context.WithTimeout(context.Background(), 10*time.Second)
defercancel()
iferr:=e.Shutdown(ctx); err!=nil {
e.Logger.Fatal(err)
}
}
Now this works perfectly fine when building and running it manually
however with air it does not work
initially it asks for permissions to tmp folder
once i set permission via chmod , I get below error
Now, I could understand the error could be in code but this works perfectly fine when building and running it manually
/Users/arvee/Documents/interview/amm-ui/goemx/tmp/main: line 1: syntax error near unexpected token `newline'
/Users/arvee/Documents/interview/amm-ui/goemx/tmp/main: line 1: `!<arch>'
So I have been trying to run htmx and have this project structure, this does work when all of these three files i.e main.go static_prod.go and static_dev.go is in root of the project alongside embed.go but with below structure it does not work
Now this works perfectly fine when building and running it manually
however with air it does not work
Now, I could understand the error could be in code but this works perfectly fine when building and running it manually
The text was updated successfully, but these errors were encountered: