fix: stabilization batch 3 — ~60 generator bugs across all commands#59
Merged
Conversation
Massive stabilization pass. Every command was audited by generating real
projects with every flag and **compiling the generated code**; this commit
fixes the bugs that broke compilation, lied about success, produced
incoherent output, or contradicted the documentation.
Verified end-to-end: `goca init` + 2 features + tricky-field entity now
produce a project that `go build ./...` compiles cleanly, with the DI
container wired into cmd/server/main.go, both feature route groups served,
and both entities registered for auto-migration.
## entity / mocks
- Convert snake_case/multi-word field names to Go PascalCase (UserID,
LastLogin) while keeping snake_case json/gorm tags (was: User_id).
- Generate stub types for custom field types instead of emitting undefined
identifiers.
- Numeric validation now covers all int/uint/float subtypes coherently;
no more unused ErrInvalid…Range constants; no required tag / dead checks
on slice/pointer fields.
- SQL seeds emit real values for slice/pointer/custom fields (was NULL).
- Mocks now implement the REAL interfaces: correct method names/signatures
and per-field finders; example test uses the real API + compile-time
interface assertions.
## usecase
- Standalone `goca usecase` compiles: generates the repository interface it
depends on and drops the contradictory usecase-package interface.
- `--async` emits real, compilable async wrappers (was undefined types).
- Generic update method uses real DTO fields (was Spanish undefined fields).
- `--dto-validation` actually calls input.Validate().
- Errors when the target entity doesn't exist. English-only output.
## repository
- Elasticsearch repo imports esapi; Mongo repo implements full CRUD.
- Postgres `--cache` generates the cache helper methods it calls (go-redis/v9).
- Cache decorator only emits finders that exist; supports `--transactions`.
- `--database` routes sqlite/sqlserver/postgres-json/elasticsearch/dynamodb
to their real generators in the field-aware path (was: all → Postgres).
## di / integrate
- `goca integrate` emits VALID Go for cmd/server/main.go (was unparseable:
missing LHS, brace/else mismatches), targets cmd/server/main.go, and only
integrates features that have all layers (skips orphan domain entities).
- `goca di --wire` produces wire-processable code (gorm DB provider, matching
return types); `--cache`/`--database mongodb` only emit constructors that
exist.
## feature (flagship auto-integration — was a no-op that printed success)
- Auto-migration actually inserts &domain.Entity{} into cmd/server/main.go.
- Routes + DI container are really wired into main.go (idempotent).
- Multiple features coexist: routes.go and the DI container are extended for
the 2nd+ feature instead of being skipped.
## handler / middleware
- handler+middleware-package output compiles (mux.MiddlewareFunc wrap).
- Shared contextKey type moved to base middleware.go (request-id et al. build).
- gRPC server uses the flat usecase output and real entity fields.
- `go mod tidy` is best-effort (no longer corrupts go.mod on failure).
- `--swagger` emits the documented @Summary/@Router/@success annotations.
- Lowercase middleware package names allowed; entity-existence is validated;
success messages are truthful (no empty-dir false success).
## init
- Validate --database/--api values; persist --api/--auth in .goca.yaml.
- DB-aware docker-compose (image/port/env/healthcheck/volume), README, and
config defaults for postgres/mysql/mongodb/sqlite/sqlserver/dynamodb/es;
mongo healthcheck uses mongosh.
- Refuse non-empty target dir without --force; fix fenced code blocks; drop
the test-only `replace` directive; git init no longer hangs on gpg/stdin.
## analyze / doctor / config / safety
- analyze no longer false-warns on goca's own layout (finds cmd/server/main.go
and os.Getenv in pkg/config); `--output json` emits valid JSON;
`--fail-on-warn` exits 2; detects `:=` hardcoded secrets.
- `config validate` uses the real semantic validator (was a stub that passed
invalid configs); `config init` validates --template/--database.
- doctor DI check no longer false-negatives; dry-run never errors on existing
files.
## template / ui / version / test-integration
- `template list` lists templates; `template show`/`reset` implemented.
- `--quiet` suppresses file/table output; `version` still prints under
`--quiet`; version reads VCS info from build metadata.
- test-integration: guards nonexistent entities, real MySQL setup (no
permanent t.Skip), real testcontainers setup for `--container`.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resumen
Pase de estabilización masivo (batch 3). Se auditaron los 24 comandos generando proyectos reales con cada flag y compilando el código generado (
go build/go vet), contrastando además contra la documentación del wiki de cada comando. Este PR corrige ~60 bugs detectados de golpe: compile-breakers, no-ops que mentían sobre el éxito, salida incoherente, flags muertos, placeholders/hardcoded y desviaciones de la documentación.Verificación end-to-end:
goca init+ 2 features + entity con campos complejos ahora produce un proyecto que compila limpio (go build ./...), con el contenedor DI cableado encmd/server/main.go, ambos grupos de rutas servidos (/api/v1/...) y ambas entidades registradas en la auto-migración.goca analyzeya no da falsos positivos,config validatedetecta configs inválidas, mocks satisfacen las interfaces reales ydi --wiregenera código procesable porwire.43 archivos · +2790/−828 · solo
cmd/einternal/testing/.Bugs corregidos por comando
entity / mocks
snake_case/multi-palabra → PascalCase Go (UserID,LastLogin) manteniendo tags json/gorm en snake_case (antesUser_id).ErrInvalid…Rangesin usar; sin tagrequired/checks muertos en slices/punteros.NULL).usecase
goca usecasestandalone compila: genera la interface de repository de la que depende y elimina la interface contradictoria en el paquete usecase.--asyncemite wrappers async reales y compilables (antes tipos indefinidos).--dto-validationahora llama ainput.Validate().repository
esapi; repo Mongo implementa CRUD completo (antes soloSave).--cachepostgres genera los helpers de caché que invoca (go-redis/v9).--transactions.--databaseenruta sqlite/sqlserver/postgres-json/elasticsearch/dynamodb a sus generadores reales en el camino field-aware (antes: todo → Postgres).di / integrate
goca integrateemite Go válido paracmd/server/main.go(antes no parseaba::=sin variable, llaves/elsemal cerrados), apunta acmd/server/main.go, y solo integra features con todas las capas (ignora entidades de dominio huérfanas).goca di --wireproduce código procesable porwire(provider de*gorm.DB, tipos de retorno consistentes);--cache/--database mongodbsolo emiten constructores existentes.feature (auto-integración estrella — antes era un no-op que imprimía éxito)
&domain.Entity{}encmd/server/main.go.main.go(idempotente).routes.goy el contenedor DI se extienden para la 2ª+ feature en vez de saltarse.handler / middleware
mux.MiddlewareFunc).contextKeycompartido movido almiddleware.gobase (request-id etc. compilan).go mod tidyes best-effort (ya no corrompego.modal fallar).--swaggeremite las anotaciones@Summary/@Router/@Successdocumentadas.init
--database/--api; persiste--api/--authen.goca.yaml.docker-composeconsciente de la DB (image/port/env/healthcheck/volume), README y defaults de config para postgres/mysql/mongodb/sqlite/sqlserver/dynamodb/es; healthcheck de mongo usamongosh.--force; arregla bloques de código markdown; elimina elreplacesolo-de-test;git initya no se cuelga por gpg/stdin.analyze / doctor / config / safety
analyzeya no da falsos positivos en el propio layout de goca (encuentracmd/server/main.goyos.Getenvenpkg/config);--output jsonemite JSON válido;--fail-on-warnsale con código 2; detecta secretos hardcoded con:=.config validateusa el validador semántico real (antes un stub que aprobaba configs inválidas);config initvalida--template/--database.doctorya no da falso negativo; dry-run nunca falla por archivos existentes.template / ui / version / test-integration
template listlista plantillas;template show/resetimplementados.--quietsuprime salida de archivos/tablas;versionsigue imprimiendo bajo--quiet;versionlee info VCS de los metadatos de build.t.Skippermanente), setup testcontainers real para--container.Notas
goca v1.25.7(idéntico al HEAD del repo), generando proyectos en distintas configuraciones y compilando/ejecutando el resultado, no solo leyendo el código.pre-commitde lefthook corrego test ./..., que incluye tests E2E eninternal/testing/testsque invocangoca init→git add/commitsin aislar el cwd, commiteando contra el.gitdel repo. Conviene aislarcmd.DireninitializeGitRepository/los tests o marcarlos como no-paralelos.template).