netlify / go-functions-example

MIT License
48 stars 58 forks source link

Doesn't actually work? #2

Open ahmetb opened 4 years ago

ahmetb commented 4 years ago

I cloned this repo, ran netlify dev and headed to http://localhost:8888/.netlify/functions/hello-lambda and got Function not found....

Is this supposed to work?

I initialized the repo with go.mod as well, that doesn't seem to help either. Since this is linked from https://docs.netlify.com/functions/build-with-go/, it should probably work?

Jeff-Tian commented 3 years ago

I didn't run it locally, but I referenced this repo and deployed to netlify, it works like a charm!

You can test it here: https://unibeta.netlify.app/.netlify/functions/hello-lambda

The build log:

1:53:33 PM: ────────────────────────────────────────────────────────────────
1:53:33 PM:   1. build.command from netlify.toml                            
1:53:33 PM: ────────────────────────────────────────────────────────────────
1:53:33 PM: ​
1:53:33 PM: $ make build
1:53:33 PM: go get ./api/...
1:53:35 PM: go build -o api/hello-lambda ./api/...

The repo: https://github.com/Jeff-Tian/beta (it's private but I invited you to access it for reference)

So you may be need to run the go build to make the function built firstly to run locally.

peteringram0 commented 3 years ago

when running locally i get the following. Im assuming this is something Netlify fills in between AWS and Netlify but how can i test the go build without this?

expected AWS Lambda environment variables [_LAMBDA_SERVER_PORT AWS_LAMBDA_RUNTIME_API] are not defined
FireMasterK commented 3 years ago

Same issue! Did anyone manage to figure this out?

I see the Function not found... message aswell.

electricsheep commented 3 years ago

According to this, netlify dev does not work with Go functions https://answers.netlify.com/t/working-with-go-functions-locally-and-in-deployment/3530/7

The Netlify CLI tool (aka netlify dev) will allow for local testing of javascript functions/lambdas but not functions/lambdas written in Go.