Open mguterl opened 3 years ago
we will investigate if there is an easy fix from our side. I don't know if generally this is a use case that we want to think about compatibility with. The user can put their cdk app anywhere, and node_modules can have a lot of stuff in it. Thinking about what unrelated commands that users can invoke that may conflict with any of the files within node_modules feels hard. In this case though if adding an empty go.mod or otherwise solves this seems easy enough.
The root cause is the filename doesn't conform to the Golang filename standards by being prefixed with a %
. It looks like the standards allow for .
and _
prefixed filenames which may be better suited.
As a side note, I've also hit this exact error while using the go vet
and go test
commands on my Golang project.
This is causing us problems too with ci cd tooling and annoying errors in VSCode... If the files were .go_tempate or something that these files would not be recognised this would not be a problem. Should be an easy fix.
I agree that an easy fix might be to rename the template from %name%.template.go
to %name%.go.template
.
Update: Actually, it's not that easy since the templating is generic and used for all languages.
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.)
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"
Using postinstall
cannot be the solution.
Running in our pipeline we need to run npm ci
which does not trigger that hook.
It also looks like that postci
does not exist.
@tenjaa Which npm version do you use? postinstall
should trigger on npm ci
too. There was an issue that in a minor version of npm v7 it was not triggered correctly but it was fixed afaik - See here: https://github.com/npm/cli/pull/2316. Maybe you have to upgrade your npm version in your pipeline?
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
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.
Environment
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: Bug Report