smithy-go currently does not generate go.mod
, go.sum
, or go_module_metadata.go
files, but it probably should.
There are example artfacts attached in this gist:
go.mod
go.sum
go_module_metadata.go
The common configurations of a go.mod
file include:
module $MODULE_NAME
go $MINIMUM_GO_VERSION
const goModuleVersion = $MODULE_VERSION
require ( $DEPENDENCY_NAME $DEPENDENCY_VERSION ... )
(handled by smithy-go)
All module-aware commands can be found in the Go Module Reference.
Currently the AWS SDK for Go v2 uses the gomodgen
tool
to generate go.mod
with the manifest generated.json
file
by using the mod/modfile
package to directly control the AST of a go.mod
file.
Potential solutions to generate go.mod
:
- Use the
go mod
commands to create thego.mod
file (Recommended)- Idiomatic way of creating
go.mod
files - This requires a dependency on
go
during the Java code generation step - Example commands:
go mod init $MODULE_NAME
go mod edit -require=$DEPENDENCY_NAME@$DEPENDENCY_VERSION
go mod edit -go=$MINIMUM_GO_VERSION
- Idiomatic way of creating
- Implement a
gomodgen
-like tool to generate ago.mod
file- This requires a dependency on
go
during the Java code generation step
- This requires a dependency on
- Use the existing
gomodgen
tool to transform agenerated.json
file into ago.mod
file- This requires a dependency on
go
during the Java code generation step - This requires a dependency on
aws-go-multi-module-repository-tools
generated.json
is a custom intermediate format, not considered idiomatic
- This requires a dependency on
- Implement a custom
go.mod
writer in Java- Manually writing
go.mod
files in Java is not considered idiomatic
- Manually writing
go.sum
files should only be generated by running go mod tidy
after go.mod
is generated.
Currently the AWS SDK for Go v2 uses the updatemodulemeta
tool
to generatego_module_metadata.go
based on git tags.
Potential solutions to generate go_module_metadata.go
:
- Implement a custom
go_module_metadata.go
writer in Java (Recommended)- This does NOT requires a dependency on git tags as a release mechanism
- Writing Go code is built-in for smithy-go, low complexity
- Implement a
updatemodulemeta
-like tool to generatego_module_metadata.go
- This requires a dependency on
go
during the Java code generation step
- This requires a dependency on
- Use the existing
updatemodulemeta
tool to generatego_module_metadata.go
- This requires a dependency on
go
during the Java code generation step - This requires a dependency on
aws-go-multi-module-repository-tools
- This requires a dependency on git tags as a release mechanism
- This requires a dependency on
Using go
in smithy-go could lead to dependency and platform complexity.
Although there are uses of go
in smithy-go, such as TestUtils.java
,
it is not common in the code generation workflows.
- smithy-go uses aws-go-multi-module-repository-tools for release automation, but not part of the code generation workflows
CodegenUtils.runCommand()
static method exists in smithy-go, but looks like it is not used (see also the OS checks)
A go
command would eventually need to be used when generated go.sum
through go mod tidy
.
Opt-in
go.mod
generation viago
commands is implemented in these two merged PRs:The PRs do not include generating
go.sum
andgo_module_metadata.go
.