Netlify Go Functions not found

I’m new to Netlify and serverless so I’m going through the simple example in the Netlify docs on functions. I’ve set up a Go function in an existing JS project. I don’t see any errors in the logs, but the Go functions are not being recognized after deploy:

And the function route is not found at /.netlify/lambda/hello

Is there another step I am missing?

TOML File with functions folder

Functions file main.go

Did you build/compile the go file in to a binary? You can do that locally on your machine or do it in our buildbot, but it has to be compiled before it can be deployed.

Thanks for the response, @futuregerald . I didn’t do a build step on my own. Definitely assumed the build would happen automatically because I set the GO_GET_PATH (probably misunderstood the documentation). Can you point me to instructions on how to use the build bot?

I ended up trying to build on my own and the functions are still not being recognized :frowning_face:

HI @yurm04,

If you’re building locally then you need to make sure you are setting the proper compile targets since it’ll be executed in a lambda container on linux. If you build on mac, then you’ll get a mac binary by default. That means your local build command would have to be something like this:

GOOS=linux GOARCH=amd64 go build function_name.go

You can build it in our build environment during your build as well. I have a go function deploying in https://github.com/futuregerald/functions-react-mongo/blob/master/src/lambda/validate-user.go

I chain the build command in my package.json as an npm script, though it can be run directly as part of your build command. The build command can be found in that repo at https://github.com/futuregerald/functions-react-mongo/blob/master/package.json#L28:

"build:lambda": "netlify-lambda build src/lambda && go get ./src/lambda/... && go build -o lambda/validate-user ./src/lambda/validate-user.go"

The relevant part for building the go function is:
go build -o lambda/validate-user ./src/lambda/validate-user.go"

Note that you still need to make sure you have your GO_IMPORT_PATH environment variable set. I have it in my netlify.toml: https://github.com/futuregerald/functions-react-mongo/blob/master/netlify.toml#L6