go: can we make generated go code more self-contained? #2847
Labels
effort/medium
Medium work item – a couple days of effort
feature-request
A feature should be added or improved.
language/go
Regarding GoLang bindings
p2
🚀 Feature Request
Affected Languages
TypeScript
orJavascript
Python
Java
C#
,F#
, ...)Go
General Information
Description
Currently, the go code generator puts the embedded jsii tarball under a subdirectory called
jsii
. This means that in order to be able to import this file, other.go
files need to know the name of the Go module in which the generated code resides.For example, the
mypackage
directory here includes the generated Go code undermypackage.go
and this file importscom.example/mymodule/mypackage/jsii
(line).This is okay for jsii-pacmak because it knows the name of the Go module, so it can render this import.
As we are looking into adding support for Go to
jsii-srcmak
(see PR), it means users of srcmak will need to pass the name of the parent go module into which we are generating source code, and this is quite a burden.Proposed Solution
We were wondering if it might be possible to avoid the
jsii
directory altogether and just embed the tarball in the main.go
file? Perhaps we can special-case the situation where there is a single.go
file? Alternatively, why does this have to be in a subdirectory? Maybe we can just put this in another .go file next to the main file (same asmypackage.init.go
) and then it will be possible to simply reference it without needing animport
statement.The text was updated successfully, but these errors were encountered: