CodeBench: --convert-model Python→Go pipeline

- 8b generoi Pythonia (osaa sen), 30b konvertoi Go:ksi
- convert-go.md prompti: FastAPI→Chi, SQLAlchemy→database/sql mappaukset
- Koodigenerointi käyttää Python golden+promptia kun convert-model asetettu
- Vaihe [3.5/5] konvertointia varten
This commit is contained in:
2026-04-14 23:54:45 +03:00
parent a16c33f4fb
commit 20a1e5f015
2 changed files with 64 additions and 4 deletions

View File

@@ -0,0 +1,25 @@
Convert the following Python FastAPI project to Go using Chi router and modernc.org/sqlite.
OUTPUT: Return ALL files with === markers:
=== go.mod ===
=== models.go ===
=== handlers.go ===
=== main.go ===
=== handlers_test.go ===
CONVERSION RULES:
- package main for all files
- Pydantic models → Go structs with json tags
- SQLAlchemy ORM → database/sql with raw SQL and RETURNING clause
- FastAPI routes → Chi router: r.Post("/path", handler(db))
- Handlers are closures: func handler(db *sql.DB) http.HandlerFunc
- Depends(get_db) → State passed via closure over *sql.DB
- HTTPException(404) → http.Error(w, "not found", http.StatusNotFound)
- POST returns http.StatusCreated (201), DELETE returns http.StatusNoContent (204)
- sql.ErrNoRows for not-found checks
- TestClient → httptest.NewServer + setupTestServer helper
- test.db → sql.Open("sqlite", ":memory:")
- Empty list: return []Entity{} not nil
- import _ "modernc.org/sqlite" (pure Go driver, no CGO)
- import "github.com/go-chi/chi/v5"
- No markdown fences in output — just raw code