-
Notifications
You must be signed in to change notification settings - Fork 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
feat: support for golang #476
Conversation
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.
I am still a bit confused here. The use case for jsii-srcmak
is to generate source code that goes into a user project. This means, for example, that the name of the Go module (i.e. github.com/foo/bar
must be derived somehow from the user project.
How do you envision the developer experience here? How will the code that calls in to srcmak
will know the base Go module, etc?
test/__snapshots__/cli.test.ts.snap
Outdated
@@ -264,6 +264,238 @@ namespace MyPackage | |||
} | |||
`; | |||
|
|||
exports[`golang output 1`] = ` | |||
Object { | |||
"package/LICENSE": "Apache License |
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.
Is this consistent with other languages? Do we really need the LICENSE file here?
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.
As nothing Go specific was added, this should be consistent with other languages.
I did a bit of digging and it seems like this was introduced via aws/jsii#2604 and this line causes the Apache License to be included.
I think we can set it to UNLICENSED
to get rid of the generated license file. However, it is already included in other snapshots already.
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.
It's odd to me that we include the license file in there. Can we remove?
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.
Setting it to UNLICENSED
worked like a charm ✅
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.
Please update README as well
Thank you for having a look at this PR, @eladb! Short Notice: I have very limited experience with Go, so please fact check and correct my assumptions 😄 My initial focus came from the use case we have with the CDK for Terraform: Generating Go modules for Terraform providers which could also be "standalone" Go modules and are not specific to the project they are generated for. So I did a bit more digging on the use case of writing project specific code in TypeScript and using it in a Go project. From what I researched, there are two possible ways to include the generated Go code:
Currently this PR does # 2 (by copying all files which were generated by Sidenote: I also built a small example to showcase how these two approaches differ when including the generated code. Without
|
@ansgarm thanks for the details. I'll get back to you tomorrow. It's a public holiday here today. |
@ansgarm I ran some tests, and I think we should go with the "without go.mod" model. Here is a sketch of how I think this could look. The root is the "parent project" and the srcmak generated stuff is under Sadly, we still need to know the @RomainMuller @MrArnoldPalmer I am wondering if we can get rid of this At any rate, I am okay with requiring the module name for now until this is changed. |
@eladb Oh yeah, it would be really nice to get rid of that I can understand the reasoning to go with just the source code. I'll update this PR accordingly. |
@RomainMuller @MrArnoldPalmer created this: aws/jsii#2847 - I think there should be something we can do about this. |
src/options.ts
Outdated
|
||
export interface GoLangOutputOptions { | ||
/** | ||
* Base root directory. |
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.
This is not accurate in case users want output to go to a nested directory
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.
Added some more information here aswell ✅
test/__snapshots__/cli.test.ts.snap
Outdated
@@ -264,6 +264,238 @@ namespace MyPackage | |||
} | |||
`; | |||
|
|||
exports[`golang output 1`] = ` | |||
Object { | |||
"package/LICENSE": "Apache License |
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.
It's odd to me that we include the license file in there. Can we remove?
will no longer create an LICENSE file in the outdir
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.
Great job 🚢
This PR extends the work done in #342 by @campionfellin
JSII now supports specifying a
packageName
for Golang (which resolves the issues Campion mentioned in his PR). I addedpackageName
as a required parameter for this library (although it isn't required when using JSII directly).I also looked into passing the generated
moduleKey
fromcompile()
back tosrcmak()
but ditched that completely as the generated Go package would be named with the generated hash. And I don't think anyone would actually want to use it that way.So I decided to keep it simple and make the
packageName
required instead.