feat: support go normal struct#24
Draft
earlgray283 wants to merge 5 commits into
Draft
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for generating Go normal structs using a new "structs" generator by introducing new testdata, templates, and generator implementation.
- Introduces test fixtures for structs in both value-modifier and math/context based scenarios.
- Adds new templates (structs.go.tmpl, structs_common.go.tmpl) and generator implementation in internal/gen/structs.
- Updates fixgen_test.go to include the "structs" generator alongside yo and ent.
Reviewed Changes
Copilot reviewed 28 out of 31 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/structs/test/testdata-value-modifier/*.go | Adds test fixtures for value modifiers for normal structs. |
| test/structs/test/testdata-math-v1/*.go | Adds new test cases for math-based generation of normal structs. |
| test/structs/test/testdata-context/*.go | Adds context-aware test cases for normal structs. |
| test/structs/test/models/*.go | Provides model definitions for the new structs. |
| test/fixgen_test.go | Updates test runner to include the new "structs" generator. |
| internal/templates/templates.go | Registers new templates for structs generation. |
| internal/gen/util.go | Adjusts directory reading functions. |
| internal/gen/structs/structs.go | Implements the new structs generator. |
| internal/gen/generator.go | Enhances error reporting for file formatting. |
Files not reviewed (3)
- internal/templates/structs.go.tmpl: Language not supported
- internal/templates/structs_common.go.tmpl: Language not supported
- test/structs/test/go.mod: Language not supported
Comments suppressed due to low confidence (1)
test/structs/test/testdata-math-v1/goldie-user.go:17
- Random ID generation here uses rand.Int63() while in similar contexts (e.g., in testdata-context) rand.Int64() is used; consider unifying the random ID function usage across tests for consistency.
ID: rand.Int63(),
| t.Helper() | ||
|
|
||
| tbl := &structs_gen.User{ | ||
| ID: rand.Int64(), |
There was a problem hiding this comment.
The use of rand.Int64() here differs from other test files; standardizing the random ID generation method may reduce potential inconsistencies in tests.
Suggested change
| ID: rand.Int64(), | |
| ID: rand.New(rand.NewSource(time.Now().UnixNano())).Int63(), |
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.
No description provided.