Working with Go functions locally and in deployment

Hi @jus,

Thanks for reaching out. I understand your frustration. I wish there was an easier path for Go functions, but Go is different since it generates a binary and the lambda handler function essentially acts as an RPC server in the function. Testing it locally won’t work easily because you can’t call it the same way you can a Javascript lambda function. You’d have to use a docker image or something similar. I don’t do this but you can find some info here.

I make heavy use of Go functions, and I personally don’t use the make file, but you of course can. I instead put the commands in npm scripts in a package.json like you can see in this repo: functions-react-mongo/package.json at master · futuregerald/functions-react-mongo · GitHub

Just to be clear, there are multiple ways of building a go function, you can chain the build function command and build site with && since the build command is just a bash shell, and you’re free to use it as such.

In terms of the local story with Go functions, as I said, it’s not easy to run them locally so you’ll end up doing something like running it in Docker. What I typically do is test them in branch deploys and also test the individual parts of the function separately. If you minimize the logic in the actual handler function and instead have other methods that are easily testable, then that would help you make sure your code is working as intended.