Skip to content

refactor(ent): add .generated.go naming suffix#283

Open
stefan-ctrl wants to merge 17 commits intofeat/cpapifrom
feat/cpapi-entc.generated.go
Open

refactor(ent): add .generated.go naming suffix#283
stefan-ctrl wants to merge 17 commits intofeat/cpapifrom
feat/cpapi-entc.generated.go

Conversation

@stefan-ctrl
Copy link
Member

add bash commands before entc generated to have .generated.go file suffixes.

BjoernKarma and others added 17 commits March 13, 2026 11:08
…ogging, panic recovery, and request timeouts from NewAppWithConfig()
…to support queries like "Get all teams of the user with email XYZ in environment ABC")
@stefan-ctrl stefan-ctrl self-assigned this Mar 18, 2026
@stefan-ctrl stefan-ctrl added enhancement New feature or request go Pull requests that update go code labels Mar 18, 2026
@stefan-ctrl stefan-ctrl requested a review from BjoernKarma March 18, 2026 09:46
@stefan-ctrl stefan-ctrl added the controlplane-api Anything related to controlplane-api label Mar 18, 2026
@BjoernKarma
Copy link
Contributor

Thank you for the PR. I had a closer look at ent and the ways to distinguish generated files from the rest. This is the summary of my findings:

File suffix like _generated.go — Not supported by ent

Ent does not support customizing generated file names. The file names are hardcoded in the ent code generator (e.g., client.go, .go, _create.go, _query.go, etc.). There's no configuration option to add a suffix.

However, this isn't really needed because:

  • Every generated file already has a clear // Code generated by ent, DO NOT EDIT. header comment (line 4 of each file)
  • Go tooling recognizes this header — go vet, editors, and golangci-lint all respect it
  • The only manual files live in ent/schema/ and ent/entc/ — everything else under ent/ is generated (~50k lines)

Separating generated and manual files by package — Already the case

Ent already organizes this well:

Directory Content Type
ent/schema/ Entity definitions and mixins Manual
ent/entc/ Code generation configuration Manual
ent/*.go Client, entity types, CRUD builders Generated
ent/<entity>/ Per-entity constants, predicates, enums Generated
ent/migrate/, ent/runtime/, ent/hook/, ent/predicate/, ent/privacy/ Framework support packages Generated

So in practice, there's already a clean separation: you only ever edit files in ent/schema/ and ent/entc/. Everything else is generated and can be safely .gitignored or regenerated at any time.

The same is true for gqlgen — the generated ent.graphql is separate from your manual schema.graphql, and the generated resolver scaffolding is in a predictable location.

tl;dr

I will add an overview in the README.md to show which files are generated. Since the structure is given and maintained by ent itself, I would vote for staying close to ent best practices and not modifying the structure internally.

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

Labels

controlplane-api Anything related to controlplane-api enhancement New feature or request go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants