Golang functions: unable to get multiValueHeaders working with netlify dev

Hi all

I am trying to build a serverless api with authentication using golang. (golang + netlify novice/intermediate)
So far I have had multiple issues with more complex setups using lambda adapters and netlify dev.
As a result I tried to narrow it down to a more hello world-like test (below), and I think I have found an issue with multi value headers, that might be causing the issue for my more complex setup.

I read in a thread that multiValueHeaders is supported in netlify, but could not find any mention of it in docs.

@futuregerald Maybe you can help?

package main

import (
	"context"
	"net/http"

	"github.com/aws/aws-lambda-go/events"
	"github.com/aws/aws-lambda-go/lambda"
)

func handler(ctx context.Context, req events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
	return events.APIGatewayProxyResponse{
		StatusCode: http.StatusOK,
		Body:       "hi",
		// this header shows up in debugging/devtools
		Headers: map[string]string{
			"X-Foo": "1",
		},
		// this doesn't seem to work
		MultiValueHeaders: map[string][]string{
			"X-Bar": {"2"},
		}
	}, nil
}

func main() {
	lambda.Start(handler)
}

Hi, @kasperstorgaard and welcome to the community! :wave:

We do have an example function with Go using MultiValueHeaders on our docs: Build functions with Go | Netlify Docs but it may not work in Netlify Dev. Are you seeing this error in production as well?

Hi @audrey, I am only seeing this when using netlify dev, on deploy previews etc. it works as expected.

At the moment, Go Functions support in CLI is not perfect. Would you mind opening an issue in the CLI repo: GitHub - netlify/cli: Netlify Command Line Interface about it so that the devs can notice it?

Done!

1 Like

This bug has now been fixed in netlify dev repo (see issue above for details)