This checklist provides a step-by-step guide for executing the migration from Macaron to Flamego.
feature/flamego-migrationgo test ./...go test -cover ./...git tag v0.14.0-pre-flamegogit branch backup/before-flamego[ ] Add Flamego core
go get github.com/flamego/flamego@latest
[ ] Add Flamego middleware
go get github.com/flamego/binding@latest
go get github.com/flamego/cache@latest
go get github.com/flamego/captcha@latest
go get github.com/flamego/csrf@latest
go get github.com/flamego/gzip@latest
go get github.com/flamego/i18n@latest
go get github.com/flamego/session@latest
go get github.com/flamego/template@latest
[ ] Run go mod tidy
[ ] Verify no conflicts
[ ] Commit: git commit -m "Add Flamego dependencies"
File: internal/cmd/web.go
[ ] Update imports
// Remove
"gopkg.in/macaron.v1"
"github.com/go-macaron/*"
// Add
"github.com/flamego/flamego"
"github.com/flamego/session"
"github.com/flamego/csrf"
// etc...
[ ] Rename function: newMacaron() → newFlamego()
[ ] Update initialization: macaron.New() → flamego.New()
[ ] Update logger: macaron.Logger() → flamego.Logger()
[ ] Update recovery: macaron.Recovery() → flamego.Recovery()
[ ] Update gzip: Keep similar pattern
[ ] Update static file serving
// Change from macaron.Static() to flamego.Static()
f.Use(flamego.Static(...))
[ ] Update renderer setup
// Change from macaron.Renderer() to template.Templater()
f.Use(template.Templater(template.Options{...}))
[ ] Test compilation: go build
[ ] Fix any compilation errors
[ ] Commit: git commit -m "Migrate main app setup to Flamego"
Still in internal/cmd/web.go:
[ ] Update i18n middleware
Langs → LanguagesDefaultLang → DefaultLanguageSubURL → URLPrefix[ ] Update cache middleware
Put() → Set()[ ] Update captcha middleware
[ ] Update toolbox functionality
Create custom health check endpoint
f.Get("/-/health", func(c flamego.Context) {
if err := database.Ping(); err != nil {
c.ResponseWriter().WriteHeader(500)
return
}
c.ResponseWriter().WriteHeader(200)
})
[ ] Update session middleware
Provider → Use config structssession.Store → session.Session[ ] Update CSRF middleware
GetToken() → Token()[ ] Test server starts: go run gogs.go web
[ ] Verify middleware loads in correct order
[ ] Commit: git commit -m "Migrate middleware to Flamego"
Still in internal/cmd/web.go:
:param → <param>^:name(a|b)$ → <name:a|b>Routes to update:
//explore/*/install/user/*/admin/*/org/*/:username/:reponame/*[ ] API routes: /api/*
[ ] Commit: git commit -m "Update route syntax to Flamego"
File: internal/context/context.go
[ ] Update imports
"github.com/flamego/flamego"
"github.com/flamego/cache"
"github.com/flamego/csrf"
"github.com/flamego/session"
[ ] Update Context struct
type Context struct {
flamego.Context // Embedded interface
cache cache.Cache
csrf csrf.CSRF
flash *session.Flash
session session.Session
// ... other fields
}
[ ] Add accessor methods
func (c *Context) Cache() cache.Cache { return c.cache }
func (c *Context) CSRF() csrf.CSRF { return c.csrf }
func (c *Context) Session() session.Session { return c.session }
[ ] Update Contexter middleware signature
func Contexter(store Store) flamego.Handler {
return func(
ctx flamego.Context,
cache cache.Cache,
sess session.Session,
// ... other injectables
) {
// ...
}
}
[ ] Update response methods
c.HTML() - needs template parameter or stored referencec.JSON() - use ResponseWriter directlyc.Redirect() - should work as-isc.PlainText() - use ResponseWriterc.ServeContent() - use ResponseWriter[ ] Update parameter access
c.Params(":name") → c.Param("name")[ ] Test compilation: go build
[ ] Commit: git commit -m "Migrate Context wrapper to Flamego"
Files in internal/context/:
auth.go - Update handler signaturesapi.go - Update APIContextuser.go - Update user context helpersrepo.go - Update repository context
c.Params() callsorg.go - Update organization contextgo_get.go - Update go-get handlerFor each file:
macaron.Handler → flamego.Handler*macaron.Context → flamego.Context or *Contextc.Params(":name") → c.Param("name")[ ] Fix compilation errors
[ ] Commit after each file or group
[ ] Final commit: git commit -m "Complete context system migration"
File: internal/form/form.go
[ ] Update imports
"github.com/flamego/binding"
[ ] Update custom validators
// Register custom validators with go-playground/validator
binding.RegisterValidation("alphaDashDot", validatorFunc)
[ ] Update SetNameMapper if used
[ ] Test validator registration
Files: internal/form/*.go
For each file:
auth.go - Update auth formsadmin.go - Update admin formsuser.go - Update user formsrepo.go - Update repo formsorg.go - Update org formsFor each form:
binding:"Required" → validate:"required"binding:"MaxSize(100)" → validate:"max=100"binding:"MinSize(5)" → validate:"min=5"Pattern replacements:
binding:"Required" → validate:"required"binding:"AlphaDashDot" → validate:"alphaDashDot"binding:"MaxSize(N)" → validate:"max=N"binding:"MinSize(N)" → validate:"min=N"binding:"Email" → validate:"email"binding:"Url" → validate:"url"
[ ] Commit: git commit -m "Migrate form binding to Flamego"
Files: internal/route/user/*.go
[ ] user.go - Basic user handlers
[ ] auth.go - Login/logout handlers
sess.Get() etc.[ ] setting.go - User settings
[ ] Test user flows:
[ ] Commit: git commit -m "Migrate user routes to Flamego"
Files: internal/route/repo/*.go
Priority files:
repo.go - Main repo handlerhome.go - Repository homeissue.go - Issue managementpull.go - Pull requestsrelease.go - Releaseswebhook.go - Webhookssetting.go - Repo settingshttp.go - HTTP Git operationsFor each file:
c.Params() calls[ ] Update form binding calls
[ ] Test repository flows:
[ ] Commit: git commit -m "Migrate repository routes to Flamego"
Files: internal/route/admin/*.go
admin.go - Admin dashboarduser.go - User managementorg.go - Organization managementrepo.go - Repository managementauth.go - Auth source management[ ] notice.go - System notices
[ ] Test admin flows:
[ ] Commit: git commit -m "Migrate admin routes to Flamego"
Files: internal/route/org/*.go
org.go - Organization handlersteam.go - Team management[ ] setting.go - Org settings
[ ] Test organization flows:
[ ] Commit: git commit -m "Migrate organization routes to Flamego"
Files: internal/route/api/v1/*.go
api.go - API router setupuser/*.go - User API endpointsrepo/*.go - Repository API endpointsorg/*.go - Organization API endpointsadmin/*.go - Admin API endpointsFor API handlers:
[ ] Test error responses
[ ] Test API endpoints:
[ ] Commit: git commit -m "Migrate API routes to Flamego"
Files: internal/route/lfs/*.go
route.go - LFS routerbasic.go - Basic authbatch.go - Batch API[ ] Update tests in *_test.go
[ ] Test LFS operations
[ ] Commit: git commit -m "Migrate LFS routes to Flamego"
Files: internal/route/*.go
home.go - Home pageinstall.go - Installation[ ] dev/*.go - Development tools
[ ] Commit: git commit -m "Migrate remaining routes to Flamego"
[ ] Update test helpers
[ ] Run unit tests: go test ./internal/context/...
[ ] Run unit tests: go test ./internal/form/...
[ ] Run unit tests: go test ./internal/route/...
[ ] Fix failing tests one by one
[ ] Document test changes
[ ] Commit: git commit -m "Fix unit tests for Flamego"
[ ] Test complete user flows
[ ] Test admin flows
[ ] Test API flows
[ ] Commit: git commit -m "Fix integration tests for Flamego"
Create test plan document covering:
Web UI:
Git Operations:
API:
Security:
Localization:
[ ] Translations load correctly
[ ] Document any issues found
[ ] Create issues for bugs
[ ] Commit fixes as they're made
[ ] Remove all Macaron imports
grep -r "gopkg.in/macaron.v1" .
grep -r "github.com/go-macaron/" .
[ ] Remove from go.mod
go mod edit -droprequire gopkg.in/macaron.v1
go mod edit -droprequire github.com/go-macaron/binding
# etc...
[ ] Run go mod tidy
[ ] Verify unused dependencies removed
[ ] Commit: git commit -m "Remove Macaron dependencies"
golangci-lint rungo fmt ./...go vet ./...git commit -m "Code quality improvements"git commit -m "Update documentation for Flamego"go test ./...If critical issues occur:
git revert <commit-range>git pushMigration is successful when:
Use this section to track:
Migration Started: _____________
Migration Completed: _____________
Total Time: _____________
Team Members: _____________
Issues Created: _____________
Issues Resolved: _____________