Skip to content

feat: support go normal struct#24

Draft
earlgray283 wants to merge 5 commits into
mainfrom
feat/datastore
Draft

feat: support go normal struct#24
earlgray283 wants to merge 5 commits into
mainfrom
feat/datastore

Conversation

@earlgray283
Copy link
Copy Markdown
Owner

No description provided.

@earlgray283 earlgray283 requested a review from Copilot March 29, 2025 10:45
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(),
Copy link

Copilot AI Mar 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(),

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants