entproto: add option to specify Go package name#616
Draft
iarunsaragadam wants to merge 2 commits intoent:masterfrom
Draft
entproto: add option to specify Go package name#616iarunsaragadam wants to merge 2 commits intoent:masterfrom
iarunsaragadam wants to merge 2 commits intoent:masterfrom
Conversation
Adds WithGoPkg extension option that allows customizing the Go package name used in the generated generate.go files. By default, the package name is still derived from the last part of the proto package, but this option enables explicit control when needed. This is useful for cases where the derived package name conflicts with Go naming conventions or when users want to align package names across generated code.
Introduces extension_test.go with test cases that verify the WithGoPkg option correctly sets custom Go package names in generated files. Tests cover both the default behavior (deriving package name from proto package) and the custom package name scenario, ensuring backward compatibility while adding the new feature.
1 task
kdevo
added a commit
to kdevo/ent-contrib
that referenced
this pull request
May 1, 2025
Basically a merge of: ent#616
kdevo
added a commit
to kdevo/ent-contrib
that referenced
this pull request
May 1, 2025
Basically a merge of: ent#616
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.
This PR adds a
WithGoPkgextension option that allows customizing the Go package name used in the generatedgenerate.gofiles.What does this PR do?
goPkgfield to theExtensionstructWithGoPkgoption function to set this fieldprotocGenerateGomethod to use the specified package name or fall back to the derived nameWhy is this needed?
By default, the package name is derived from the last part of the proto package, but this option enables explicit control when needed. This is useful for cases where:
Test Plan
Added unit tests that verify:
WithGoPkgoption correctly sets the extension's package name