-
Notifications
You must be signed in to change notification settings - Fork 0
gentypes: add support for third-party types #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
2befa5b
to
21009e2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can actually add these methods if there is a reason for it. We have already been asked for these features:
90fa741
to
6ef344a
Compare
There was a problem hiding this 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 extends the gentypes tool to support generating optional types for third-party types. Previously, the tool was limited to generating optional types for local types that implemented MarshalMsgpack and UnmarshalMsgpack methods.
- Adds support for third-party types with new command-line flags (-force, -imports, -marshal-func, -unmarshal-func)
- Refactors the generator to use a GenerateOptions struct for better organization
- Includes comprehensive test coverage for uuid.UUID as an example third-party type
Reviewed Changes
Copilot reviewed 14 out of 17 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
cmd/gentypes/main.go | Adds new CLI flags and logic for handling third-party types |
cmd/gentypes/generator/extension.go | Refactors GenerateByType to use GenerateOptions struct |
cmd/gentypes/generator/type_gen.go.tpl | Updates template to support custom marshal/unmarshal functions |
cmd/gentypes/flag.go | Implements stringListFlag type for handling multiple imports |
cmd/gentypes/internal/test/uuid_gen.go | Generated optional type for uuid.UUID as test case |
README.md | Documents new flags and provides usage examples |
go.mod | Adds github.com/google/uuid dependency |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
6ef344a
to
e519233
Compare
@oleg-jukovec I've redone this logic once again :( now it has more examples and has even better support for third-party libraries. |
The gentypes tool was previously limited to generating optional types for local types that implemented the MarshalMsgpack and UnmarshalMsgpack methods. Thi made it impossible to generate optional types for types from external modules. This commit enhances the generator to support third-party types by introducing the following new flags: * -force: To bypass the check for MarshalMsgpack and UnmarshalMsgpack methods. * -imports: To add necessary imports for the third-party type and custom functions. * -marshal-func: To specify a custom marshal function. * -unmarshal-func: To specify a custom unmarshal function. The generator code has been refactored to use a GenerateOptions struct for better organization. Additionally, this commit: * Adds a new test case for generating an optional type for uuid.UUID. * Updates the README.md with documentation for the new flags and an example. * Moves test files to a more appropriate internal/test directory. Closes #TNTP-3734.
e519233
to
ecdf7af
Compare
The gentypes tool was previously limited to generating optional types for local
types that implemented the MarshalMsgpack and UnmarshalMsgpack methods. Thi
made it impossible to generate optional types for types from external modules.
This commit enhances the generator to support third-party types by introducing
the following new flags:
The generator code has been refactored to use a GenerateOptions struct for
better organization.
Additionally, this commit:
Closes #TNTP-3734.