Skip to content

Commit

Permalink
fix(go): shorten file names for sub-packages (#3927)
Browse files Browse the repository at this point in the history
CDKTF is running into build issues one some providers due to file names being too long for golang to handle: https://github.com/cdktf/cdktf-provider-googlebeta/actions/runs/4002506018/jobs/6869839656#step:8:11

This is my slightly naive try to get rid of a few characters (especially with long package names)

---

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

[Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
  • Loading branch information
DanielMSchmidt committed Feb 3, 2023
1 parent d0e4267 commit 7697571
Show file tree
Hide file tree
Showing 4 changed files with 20,733 additions and 20,750 deletions.
2 changes: 1 addition & 1 deletion packages/@jsii/java-runtime/pom.xml.t.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ process.stdout.write(`<?xml version="1.0" encoding="UTF-8"?>
<javax-annotations.version>[1.3.2,1.4.0)</javax-annotations.version>
<jetbrains-annotations.version>[13.0.0,24.0-a0)</jetbrains-annotations.version>
<junit.version>[5.8.0,5.10-a0)</junit.version>
<mockito.version>[3.12.4,4.0-a0)</mockito.version>
<mockito.version>[4.11.0,5.0-a0)</mockito.version>
</properties>
<dependencies>
Expand Down
25 changes: 4 additions & 21 deletions packages/jsii-pacmak/lib/targets/go/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export abstract class Package {
if (this.types.length > 0) {
const { code } = context;

const initFile = join(this.directory, `${this.packageName}.go`);
const initFile = join(this.directory, `main.go`);
code.openFile(initFile);
code.line(`package ${this.packageName}`);
code.line();
Expand Down Expand Up @@ -238,10 +238,7 @@ export abstract class Package {

private emitTypes(context: EmitContext) {
for (const type of this.types) {
const filePath = join(
this.directory,
`${this.packageName}_${type.name}.go`,
);
const filePath = join(this.directory, `${type.name}.go`);
context.code.openFile(filePath);

this.emitHeader(context.code);
Expand All @@ -266,23 +263,9 @@ export abstract class Package {
return;
}

emit.call(
this,
join(
this.directory,
`${this.packageName}_${type.name}__runtime_type_checks.go`,
),
false,
);
emit.call(this, join(this.directory, `${type.name}__checks.go`), false);

emit.call(
this,
join(
this.directory,
`${this.packageName}_${type.name}__no_runtime_type_checking.go`,
),
true,
);
emit.call(this, join(this.directory, `${type.name}__no_checks.go`), true);

function emit(this: Package, filePath: string, forNoOp: boolean) {
code.openFile(filePath);
Expand Down
Loading

0 comments on commit 7697571

Please sign in to comment.