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:
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?
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:
@rof, I’m not sure what you mean, why would you put them in the same file? Each function has to be it’s own file. You can change the building of multiple Go functions in the same way that you build one. each needs to be its own binary at the end of your build process. For example I have a private repo that uses the following build command that builds multiple Go functions:
"build:functions": "mkdir -p functions && go get ./src/functions/... && go build -o functions/fetchunanswered ./src/functions/fetchunanswered/fetchunanswered.go && go build -o functions/openhelpdeskconvo ./src/functions/openhelpdeskconvo/openhelpdeskconvo.go && go build -o functions/savetonotes ./src/functions/savetonotes/savetonotes.go && go build -o functions/fetchunanswerednewtopics ./src/functions/fetchunanswerednewtopics/fetchunanswerednewtopics.go && go build -o functions/tagunanswered ./src/functions/tagunanswered/tagunanswered.go && go build -o functions/fetchrecentpostbyemail ./src/functions/fetchrecentpostbyemail/fetchrecentpostbyemail.go && go build -o functions/tagansweredbutton ./src/functions/tagansweredbutton/tagansweredbutton.go && go build -o functions/tagsolvedbystaff ./src/functions/tagsolvedbystaff/tagsolvedbystaff.go && go build -o functions/fetchadmintopics ./src/functions/fetchadmintopics/fetchadmintopics.go"