Ok so I have been having another set of problems w...
# help
s
Ok so I have been having another set of problems with the Golang version of the rest example. Any hints as to what might be causing the issue here would be very much appreciated.
t
yeah the issue here is because we need to create a subfolder for each lambda
so we have everything in
backend/*.go
should be
backend/get/get.go
or maybe
backend/get/main.go
s
k, thanks I will try that
I tried both those options along with changing the MyStack.ts to match. The Go Errors disappeared but I'm still not getting a response from the deployed API
Stacks: Deploying completed. 07e5db93-ec32-47f8-a7fb-d983f26adc3a REQUEST dev-rest-api-go-MyStack-ApiLambdaGETnotesA3E56CF7-HVTN1E5CbN6x [functions/list/main.go] invoked by API GET /notes 'C:\Repositories\rest-api-go\.sst\artifacts\dev-rest-api-go-MyStack-Api-Lambda_GET_-notes\handler' is not recognized as an internal or external command, operable program or batch file. Error: spawn C:\Repositories\rest-api-go\.sst\artifacts\dev-rest-api-go-MyStack-Api-Lambda_GET_-notes\handler ENOENT at notFoundError (C\Repositories\rest api go\node modules\cross spawn\lib\enoent.js6:26) at verifyENOENT (C\Repositories\rest api go\node modules\cross spawn\lib\enoent.js40:16) at ChildProcess.cp.emit (C\Repositories\rest api go\node modules\cross spawn\lib\enoent.js27:25) at Process.ChildProcess._handle.onexit (nodeinternal/child process290:12) ``````
t
can you check if
handler
is in that folder?
and can you run a manual build of the lambda just in case to see if there are issues
go build functions/list/main.go
s
There is definately no handler file anywhere. I tried running the build cmd and nothing happened
*definitely
t
the build command doesn't generate a file called
main
in your cwd?
s
it did build it. should I run it?
t
hm if it built successfully I wonder why it's not building when hitting the api
does this folder exist:
Copy code
C:\Repositories\rest-api-go\.sst\artifacts\dev-rest-api-go-MyStack-Api-Lambda_GET_-notes\
s
That folder exists but there is nothing in it
however below it there is a file with the same name except a -{id} at the end and it has a binary file called handler in it.
t
can you run this
s
*folder with the same name
t
Copy code
go build -ldflags "-s -w" -o "C:\Repositories\rest-api-go\.sst\artifacts\dev-rest-api-go-MyStack-Api-Lambda_GET_-notes\handler" ./functions/list/main.go
s
2022/05/14 184353 expected AWS Lambda environment variables [_LAMBDA_SERVER_PORT AWS_LAMBDA_RUNTIME_API] are not defined
t
that's when you run it but does the build succeed?
s
That result was from what appeared in the folder after I tried npm run start again. When I run the build script you gave me I get this:
Copy code
go build -ldflags "-s -w" -o "C:\Repositories\rest-api-go\.sst\artifacts\dev-rest-api-go-MyStack-Api-Lambda_GET_-notes\handler" ./functions/list/main.go
oopps
go: cannot find main module,
I have my handler go files as package main if that makes any difference and MyStack.ts routes are pointed at "functions/list/main.go" etc....
t
I'd try to figure out why that command fails, are you running it in the backend folder?
I'm less familiar with windows so not sure if the path style matters
/ vs \
s
yes, I'm in the backend folder
Is it possible that the reason I'm having so much trouble with this is because Everyone else who tries to use SST is on Mac?
t
I'm on Linux and the rest of the SST team works on Macs so the windows side gets less attention
s
I just tried the sst build and got this error:
Synthesizing CDK Building function functions/list/main.go Error: EBUSY: resource busy or locked, rmdir 'C:\Repositories\rest-api-go\.sst\artifacts\dev-rest-api-go-MyStack-Api-Lambda_GET_-notes' at Object.rmdirSync (nodefs1167:10) at rmdirSync (C\Repositories\rest api go\node modules\fs extra\lib\remove\rimraf.js264:13) at Object.rimrafSync (C\Repositories\rest api go\node modules\fs extra\lib\remove\rimraf.js243:7) at Object.bundle (C:\Repositories\rest-api-go\node_modules\@serverless-stack\core\dist\runtime\handler\go.js2932) at Object.bundle (C:\Repositories\rest-api-go\node_modules\@serverless-stack\core\dist\runtime\handler\handler.js1916) at new Function (C:\Repositories\rest-api-go\node_modules\@serverless-stack\resources\src\Function.ts72839) at Function.fromDefinition (C:\Repositories\rest-api-go\node_modules\@serverless-stack\resources\src\Function.ts94214) at Api.createFunctionIntegration (C:\Repositories\rest-api-go\node_modules\@serverless-stack\resources\src\Api.ts111823) at C:\Repositories\rest-api-go\node_modules\@serverless-stack\resources\src\Api.ts98416 at Api.addRoute (C:\Repositories\rest-api-go\node_modules\@serverless-stack\resources\src\Api.ts10227)
weird. It works perfectly when deployed on lambda but on the local version it continues to have the issue with executing the handler
t
how are you deploying?
s
npm run deploy
f
Hey @Schuyler Sloane are you still having the issue?
Error: EBUSY: resource busy or locked, rmdir ‘C:\Repositories\rest-api-go\.sst\artifacts\dev-rest-api-go-MyStack-Api-Lambda_GET_-notes’
Do you have a file open from this directory? Maybe that’s preventing the folder to get deleted on rebuild?