Skip to content

Remove Echo dependency and upgrade to Go 1.24#872

Open
statik wants to merge 2 commits intomainfrom
claude/upgrade-pocketbase-sYmyT
Open

Remove Echo dependency and upgrade to Go 1.24#872
statik wants to merge 2 commits intomainfrom
claude/upgrade-pocketbase-sYmyT

Conversation

@statik
Copy link
Member

@statik statik commented Jan 29, 2026

Summary

This PR removes the Echo web framework dependency and replaces it with Go's standard library net/http and http.ServeMux. Additionally, it upgrades the project to Go 1.24.0 and updates PocketBase to v0.36.1, which includes API changes that align with this refactoring.

Key Changes

  • Removed Echo framework: Replaced all Echo-specific code with standard library equivalents

    • Removed github.com/labstack/echo/v5 dependency from go.mod and build files
    • Replaced echo.New() with http.NewServeMux() in cmd/lighting.go
    • Updated route registration to use mux.Handle() instead of Echo's route methods
    • Replaced echo.WrapHandler() with apis.WrapStdHandler() for PocketBase integration
  • Updated Go version:

    • Bumped Go version from 1.21 to 1.24.0 in go.mod
    • Added toolchain go1.24.7 directive
    • Updated Bazel Go toolchain registration to 1.24.0
    • Updated vendor.sh compatibility flag from 1.18 to 1.24
  • Updated PocketBase:

    • Upgraded from v0.16.5 to v0.36.1
    • Updated migration command API: migratecmd.Optionsmigratecmd.Config
    • Updated event hook API: app.OnBeforeServe()app.OnServe().BindFunc()
    • Updated route registration to use new PocketBase router methods: apis.Static() and apis.WrapStdHandler()
    • Changed pocketbase.NewWithConfig(&pocketbase.Config{}) to pocketbase.NewWithConfig(pocketbase.Config{})
  • Simplified embedder:

    • Removed Echo dependency from embeddy package
    • Replaced echo.MustSubFS() with standard fs.Sub() in both embeddy/embedder.go and sitemanifest/main.go
  • Code organization:

    • Alphabetized load statements in BUILD.bazel for consistency
    • Reordered attributes in Bazel rules for better readability

Implementation Details

The refactoring maintains the same functionality while using only Go standard library for HTTP handling. The http.ServeMux provides the necessary routing capabilities, and PocketBase's newer APIs (apis.Static(), apis.WrapStdHandler()) handle the integration seamlessly. All route patterns were updated to use the new Go 1.22+ syntax (e.g., GET /{path...} instead of /*).

https://claude.ai/code/session_01XWLJELDi6wxFXL95EVXoAQ

PocketBase v0.23.0 introduced a major API redesign. Key changes:
- Use OnServe().BindFunc() instead of OnBeforeServe().Add()
- Use new router API (Go 1.22 mux patterns) instead of Echo
- Use migratecmd.Config instead of migratecmd.Options
- Use apis.Static() for serving embedded files
- Use apis.WrapStdHandler() for wrapping http.Handler
- Replace echo with stdlib net/http in lighting bridge
- Replace echo.MustSubFS with io/fs.Sub in embeddy
- Upgrade Go toolchain to 1.24.0 (required by PocketBase)
- Remove labstack/echo/v5 dependency entirely

https://claude.ai/code/session_01XWLJELDi6wxFXL95EVXoAQ
Resolve conflicts from main:
- Keep dynamic Go version reading from go.mod in WORKSPACE
- Keep PocketBase v0.36.1 API changes while incorporating error handling
- Keep Go 1.24.0 version required by PocketBase v0.36.1

https://claude.ai/code/session_01XWLJELDi6wxFXL95EVXoAQ
@statik statik enabled auto-merge February 13, 2026 03:52

log.Debug().Msgf("running pocketbase with data dir %s\n", configDir)
app := pocketbase.NewWithConfig(&pocketbase.Config{
app := pocketbase.NewWithConfig(pocketbase.Config{
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci] reported by reviewdog 🐶
pocketbase.Config is missing fields HideStartBanner, DefaultDev, DefaultEncryptionEnv, DefaultQueryTimeout, DataMaxOpenConns, DataMaxIdleConns, AuxMaxOpenConns, AuxMaxIdleConns, DBConnect (exhaustruct)

mux.Handle("GET /{path...}", assetHandler)
mux.Handle("POST /api/switcher/{path...}", &Switcher{})
mux.Handle("POST /api/light/{path...}", &Lighting{})
err = http.ListenAndServe(listenAddr, mux)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci] reported by reviewdog 🐶
G114: Use of net/http serve function that has no support for setting timeouts (gosec)

})

app.OnBeforeServe().Add(func(e *core.ServeEvent) error {
app.OnServe().BindFunc(func(e *core.ServeEvent) error {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci] reported by reviewdog 🐶
parameter name 'e' is too short for the scope of its usage (varnamelen)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants