Go lambdas: differences with AWS lambdas prevents me from using algnhsa

Hi! :wave:

I’m trying to refactor a golang lambda I’m currently running in production to use akrylysov/algnhsa to be able to test more easily, since it is not possible to run go lambdas in Netlify Dev yet.

algnhsa is overall working but I’m having issues setting headers. To replicate, deploy this function to both, Netlify Functions and AWS Lambda + API Gateway and curl it:

package main

import (


func handler(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("location", "https://en.wikipedia.org")

func main() {
	http.HandleFunc("/", handler)
	algnhsa.ListenAndServe(http.DefaultServeMux, nil)

You will notice the location header is there for the AWS Lamda but it is not for the Netlify Function.

I’ve deployed the very same code above to both for you to test:


To clarify, if I use the regular lambda handler signature that takes events.APIGatewayProxyRequest and returns an events.APIGatewayProxyResponse, it does work (it is what I have in production right now). Adding algnhsa as a compat layer works on AWS Lambda but strips the location header in Netlify Functions.

So it makes me think there’s some other layer in Netlify Functions that might be out of sync with the AWS interface .

I ran some more tests and indeed it seems somehow the interface for Netlify Functions doesn’t match that of AWS Lambda.

The MultiValueHeaders field of the events.APIGatewayProxyResponse gets ignored in Netlify Functions:

package main

import (

func handler(request events.APIGatewayProxyRequest) (*events.APIGatewayProxyResponse, error) {
	return &events.APIGatewayProxyResponse{
		StatusCode: 301,
		MultiValueHeaders: map[string][]string{
			"Location": []string{"https://en.wikipedia.org"},
	}, nil

func main() {

The code above works as expected in AWS Lambda but, again, lacks the location header on Netlify Functions.

Since algnhsa uses MultiValueHeaders, as seen here, it doesn’t work with Netlify Functions.

It is my understanding that Netlify Functions actually run in AWS Lambda. How does it work? Aren’t the binaries uploaded as they are? Are the aws-lambda-go dependencies hijacked during deploy? :thinking:

Ok so probably related to this: Multiple `Set-Cookie` headers cause netlify lambda to throw an error

hi @stefanmaric, thank you sooo much for digging in to this. You’re correct. We don’t use API gateway, we use our own, and it seems we don’t yet have support for MultiValueHeaders. I’ve gone ahead and filed an issue about this for our team to look at. I don’t anticipate a fast turnaround, but we’ll let you know when we have more info.

Hope it gets some traction. :crossed_fingers:

My team has a few new experimental projects kicking off and this is kinda holding us back because we need to be able to test locally (and I don’t see go support coming to netlify-dev anytime soon). Of course we might as well run it directly on AWS Lambda, but would rather skip all the boilerplate and setup and take advantage of the CI/CD flow we already use for our frontends.