go-functions-example icon indicating copy to clipboard operation
go-functions-example copied to clipboard

Doesn't actually work?

Open ahmetb opened this issue 5 years ago • 4 comments

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?

ahmetb avatar Oct 09 '20 19:10 ahmetb

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.

Jeff-Tian avatar Dec 18 '20 06:12 Jeff-Tian

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

peteringram0 avatar Feb 21 '21 22:02 peteringram0

Same issue! Did anyone manage to figure this out?

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

FireMasterK avatar Apr 22 '21 05:04 FireMasterK

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.

electricsheep avatar Apr 29 '21 15:04 electricsheep