Skip to content
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(golang): introduce Golang code generation #1551

Merged
merged 60 commits into from
Aug 21, 2020

Conversation

RomainMuller
Copy link
Contributor

@RomainMuller RomainMuller commented Apr 15, 2020

Adds a new GoLang code generation handler. The handler defines Go specific
generators for JSII submodules, interfaces, structs, and enums. The directory
structure of the generated code mirrors public submodules and namespaces defined
in the JSII module, ie, there is one file per namespace. The generated type
model is in progress and subject to change.

Adds documentation to docs/configuration.md about configuring the Go target.
Go code generation can be enabled by adding the go key to the jsii section
of your package.json.

{
  "jsii": {
    "targets": {
      "go": {}
    }
  }
}

The Go target is not currently supported for production use. This is the first
iteration of code generation and does not define a target runtime library.

Relates to #83


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

A new `Golang` code generation handler was added. It is a very early
work-in-progress. Further development should happen mostly within
`lib/targets/golang`, adding new classes and completing the `emit`
handler to handle the element types.

Disclaimer: some of the currently generated code may not be valid Go...
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Apr 15, 2020
SoManyHs and others added 8 commits June 16, 2020 00:23
Structs and interfaces should not all be lowercased.

Also adds newline after writing to-level package name and removes extra
whitespace after method definitions.

TODO:
- Handle `any` type (does not exist in go)
- Handle type unions
- Capitalize any exported methods
- Handle method arguments
MrArnoldPalmer and others added 19 commits August 17, 2020 21:03
Add some doc comments and cleanup.

Changes the `Module` interface to an abstract base class that is
extended by `Package` and `Submodule` to avoid repeating module build
and emit logic.

Change dynamic getters for module submodules and types to be built and
set in constructor to avoid unecessary recomputation.
Minimizes changes to interface type for refactoring to class layout
based on struct/interface differences.
Adds a section about configuring GoLang code generation in
`docs/configuration.md`. Notes that go code generation is experimental
and is not suitable for production use.

Update snapshots.
Renames module related classes to be more idiomatic to go package output.
BasePackage => Package
Package => RootPackage

Note: RootPackage could be thought of as "module", but we are reserving
that word due to "go mod"
Removes the embedded runtime logic until an appropriate alternative is
identified. The current strategy was causing the output byte array
inside the snapshots to differ from user to user based on build
environment.

Fixes casing in `goModuleName` util to be all lower case.
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-Blkkw9bQFn8A
  • Commit ID: 541d714
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@MrArnoldPalmer MrArnoldPalmer marked this pull request as ready for review August 21, 2020 00:17
@MrArnoldPalmer MrArnoldPalmer added the pr/do-not-merge This PR should not be merged at this time. label Aug 21, 2020
@MrArnoldPalmer MrArnoldPalmer self-assigned this Aug 21, 2020
@MrArnoldPalmer MrArnoldPalmer self-requested a review August 21, 2020 00:18
@MrArnoldPalmer MrArnoldPalmer removed their assignment Aug 21, 2020
Copy link
Contributor

@SoManyHs SoManyHs left a comment

Choose a reason for hiding this comment

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

lezdothis

@MrArnoldPalmer MrArnoldPalmer merged commit 2833db4 into master Aug 21, 2020
@MrArnoldPalmer MrArnoldPalmer deleted the golang/code-generation branch August 21, 2020 01:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS. pr/do-not-merge This PR should not be merged at this time.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants