Open justinmk3 opened 3 years ago
The issues are unrelated though the concepts are similar. This mainly is an issue with what CodeUri
means. For Go templates, this must be the direct parent directory of the handler file, while for other runtimes the Handler
property can be a relative path to the file, starting from CodeUri
. Our code right now is fine, albeit pretty confusing. rootUri
becomes projectRoot
becomes codeRoot
becomes CodeUri
as it progresses from CodeLens -> Launch config -> Debug config -> Final template
In my opinion, CodeUri
referring to the manifest file's parent directory is the correct interpretation (it should be named ProjectUri
). SAM CLI just doesn't handle that use case for Go.
I'm bumping it up, as I've just lost a couple of hours before I discovered that I need to manually adjust the projectRoot to run and debug lambda put in a subfolder.
Another unexpected behaviour that I noticed is that when:
launch.json
to properly debug my lambda put in subfolder handler1.go
invokes function in function.go
)\---WorkspaceFolder
\---lambda
\---handler1.go
\---another-package
\---function.go
\---go.mod
then the breakpoint put in the handler1.go is not hit, whereas the breakpoint put inside the function.go works.
I am new to golang and AWS sam, so I don't know if those issues are related or not.
sam cli now supports this: https://github.com/aws/aws-lambda-builders/pull/406
Problem
Go support was added in Toolkit 1.25, but there is a known limitation:
If a Go handler is defined in
./foo/bar/baz.go
but the manifest is defined in an ancestor directory/.foo/
, user cannot define a launch config that works.Solution
PR: https://github.com/aws/aws-toolkit-vscode/pull/1688
projectRoot
sam
, before invokingsam build
Status
Waiting for feedback from SAM CLI: https://github.com/aws/aws-sam-cli/issues/2844