-
Notifications
You must be signed in to change notification settings - Fork 53
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
feat(codegen): create go.mod file automatically #405
Conversation
Hi @eduardomourar, thanks for the contribution! I was wondering if it would be possible to provide an example of how this feature would work, and how this change was tested? |
At Stedi, we are starting to generate the Go client SDKs based on our own Smithy models. In order to use our tooling for managing the modules' version, it made more sense to create, at least, the go.mod as part of the codegen. We have tested this internally with all services, but we are not ready to make this repository public just yet. I will try to either create a sample repo or maybe include some basic test to this PR. |
We really appreciate your contribution! Right now no one is able to review your PR. We will try to address is as part of 2023 efforts. Thanks again! |
Hey @eduardomourar! I had a few suggestions for this feature:
|
The To assert on |
I tried but it is actually failing while running the go command with |
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.
Left a few comments, but overall looks good.
The go.mod
output in smithy-go-codegen-test
gradle subproject looks correct at path codegen/smithy-go-codegen-test/build/smithyprojections/smithy-go-codegen-test/source/go-codegen/go.mod
:
module github.com/aws/smithy-go/internal/tests/service/weather
go 1.18
require (
github.com/aws/smithy-go v1.4.0
github.com/jmespath/go-jmespath v0.4.0
)
codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/GoModGenerator.java
Outdated
Show resolved
Hide resolved
codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/GoSettings.java
Outdated
Show resolved
Hide resolved
codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/GoSettings.java
Outdated
Show resolved
Hide resolved
codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/CodegenVisitor.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Steven Yuan <[email protected]>
Issue #, if available: N/A
Description of changes:
In order to simplify the management of the generated Go files and well as allowing some customization, this will introduce the following changes:
moduleVersion
in the codegen setttings will allow consumers to pass the version that they manage user their own tooling outside Smithygo.mod
will automatically be generated whenever a settings calledgenerateGoMod
is set to truebased on the template located atcodegen/smithy-go-codegen/src/main/resources/software/amazon/smithy/go/codegen/go.mod.template
The filego_module_metadata.go
will generated containing the version of the module provided by the userBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.