question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(aws-cdk): go template breaks go list

See original GitHub issue

#13840 added an app template for go and the filenames break go list ./... when cdk project is embedded inside of a Go project.

Reproduction Steps

mkdir project
cd project
cdk init app --language=typescript
go mod init github.com/test/project
echo "package main\nfunc main() { return }\n" > main.go
go list ./... # fails because of template files

package github.com/test/project/node_modules/aws-cdk/lib/init-templates/v1/app/go: invalid input file name "%name%.template.go"

What did you expect to happen?

I expected go list ./... to return a list of package names.

What actually happened?

List of package name was not returned and an error was returned instead.

package github.com/test/project/node_modules/aws-cdk/lib/init-templates/v1/app/go: invalid input file name "%name%.template.go"

Environment

  • CDK CLI Version: 1.96.0 (build 39f3df8)
  • Framework Version: ?
  • Node.js Version: v15.13.0
  • OS : macOS 11.2.3
  • Language (Version): all
  • Go (Version): 1.16.3

Other

I think it might be possible to add an empty go.mod file into the template directory to prevent this from happening, but I’m hardly an expert in Go.


This is 🐛 Bug Report

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:16
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
mlafeldtcommented, May 7, 2021

Here’s my dirty quickfix for now:

--- package.json
+++ package.json
@@ -8,7 +8,8 @@
     "build": "tsc",
     "watch": "tsc -w",
     "test": "jest",
-    "cdk": "cdk"
+    "cdk": "cdk",
+    "postinstall": "rm -rf node_modules/aws-cdk/lib/init-templates/v1/app/go"
   },

(We don’t need those templates in already initialized projects anyway.)

3reactions
mlafeldtcommented, Jun 11, 2021

Since this is still a problem and there’s now a v2 template for Go, I had to update my workaround a bit:

"postinstall": "rm -rf node_modules/aws-cdk/lib/init-templates/*/app/go"
Read more comments on GitHub >

github_iconTop Results From Across the Web

Working with the AWS CDK in Go
cdk synth : Synthesizes a AWS CloudFormation template from one or more of the stacks in your AWS CDK app. cdk deploy :...
Read more >
awscdk - Go Packages
An experiment to bundle the entire CDK into a single module.
Read more >
AWS CDK with Golang - poweruser.blog
Like sourcing from example cloudformation templates found on GitHub. Or another one would be using the AWS WebUI to provision infrastructure by ...
Read more >
Go project containing Typescript AWS-CDK directory has ...
npx cdk init app --language typescript cd .. mkdir src cd src go mod init example go mod tidy cd .. This creates...
Read more >
Go - Noise
The AWS CDK mounts the folder specified as the first argument to fromAsset at /asset-input inside the container, and mounts the asset output...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found