Skip to content

Conversation

@brucechen7274
Copy link
Contributor

What have I done:

  1. Enhanced Import Statement Generation Logic: Refactored the import handling of the code generator, which now groups and sorts imports according to Go conventions (standard library, third-party libraries, local libraries).
  2. New Datetime Type Support: RFC3339 format.
  3. Enhanced Type Validation: Added field type existence validation to ensure referenced types are defined in the specification.

Other things:

If my implementation is okay, do I need to change the date-related fields in the example from string to datetime?

@brucechen7274
Copy link
Contributor Author

Maybe the parts of generating import code are too complex 🤣

Copy link
Owner

@ostafen ostafen left a comment

Choose a reason for hiding this comment

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

Left some minor comments. Other than that, looks good!

pkg/gen/gogen.go Outdated
// 3. Third-party imports (sorted)
// 4. Blank line
// 5. Local/project imports (sorted)
func (gen *CodeGenerator) generateImports(requiredImports map[string]bool) {
Copy link
Owner

Choose a reason for hiding this comment

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

I think we can use golang.org/x/tools/imports package to format code. That also handles imports.

Example:

 formattedSrc, err := imports.Process("", src, nil)
    if err != nil {
        log.Fatal(err)
    }

    fmt.Println(string(formattedSrc))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

using golang.org/x/tools/imports is a realy eazy way to format our generated code, this makes it completely unnecessary for us to import via a slice of constants.

@ostafen ostafen merged commit cd42837 into ostafen:main Aug 17, 2025
1 check passed
@ostafen
Copy link
Owner

ostafen commented Aug 17, 2025

Thanks, @brucechen7274!

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