Go Lambda not found in netlify/functions

Help! I can’t (quite) figure out how to deploy a go functions as a Lambda. I’m following the documentation (Build functions | Netlify Docs) and made my hello.go and dutifully put it into ./netlify/functions but it keeps saying not found, I added a GO_IMPORT_PATH in netlify.toml pointing to the github.com/richtong/covid-scraper-test` but still no joy.

It would be really great if we could use the build feature that they talk about.

I am confused by the documentation since the function is actually way down deep and not at the top level of that repo,

So frustrating just trying to follow the documentation to make a hello world app :slight_smile:

The deployment site is covidwa-test.netlify.app and the build results are:

Loading

  • The test site is covidwa-test.netlify.app
2:52:40 PM: Build ready to start
2:52:42 PM: build-image version: d84c79427e8f83c1ba17bcdd7b3fe38059376b68
2:52:42 PM: build-image tag: v3.6.1
2:52:42 PM: buildbot version: 4c3d8713ccd4c98ab9180f79a013d42d2076d9ff
2:52:42 PM: Fetching cached dependencies
2:52:42 PM: Starting to download cache of 113.9MB
2:52:43 PM: Finished downloading cache in 1.331391936s
2:52:43 PM: Starting to extract cache
2:52:46 PM: Finished extracting cache in 2.620676315s
2:52:46 PM: Finished fetching cache in 3.986958724s
2:52:46 PM: Starting to prepare the repo for build
2:52:46 PM: Git LFS enabled
2:52:46 PM: Preparing Git Reference refs/heads/main
2:52:48 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'public' versus '.' in the Netlify UI
2:52:48 PM: Different functions path detected, going to use the one specified in the Netlify configuration file: 'netlify/functions' versus '' in the Netlify UI
2:52:48 PM: Different build command detected, going to use the one specified in the Netlify configuration file: 'hugo --gc --minify' versus 'hugo' in the Netlify UI
2:52:48 PM: Starting build script
2:52:48 PM: Installing dependencies
2:52:48 PM: Python version set to 2.7
2:52:49 PM: Started restoring cached node version
2:52:51 PM: Finished restoring cached node version
2:52:52 PM: v12.18.0 is already installed.
2:52:52 PM: Now using node v12.18.0 (npm v6.14.4)
2:52:53 PM: Started restoring cached build plugins
2:52:53 PM: Finished restoring cached build plugins
2:52:53 PM: Attempting ruby version 2.7.1, read from environment
2:52:54 PM: Using ruby version 2.7.1
2:52:54 PM: Using PHP version 5.6
2:52:54 PM: Installing Hugo 0.80.0
2:52:54 PM: Hugo Static Site Generator v0.80.0-792EF0F4/extended linux/amd64 BuildDate: 2020-12-31T13:46:18Z
2:52:54 PM: Started restoring cached go cache
2:52:54 PM: Finished restoring cached go cache
2:52:54 PM: go version go1.14.4 linux/amd64
2:52:54 PM: go version go1.14.4 linux/amd64
2:52:54 PM: Installing missing commands
2:52:54 PM: Verify run directory
2:52:56 PM: ​
2:52:56 PM: ────────────────────────────────────────────────────────────────
2:52:56 PM:   Netlify Build                                                 
2:52:56 PM: ────────────────────────────────────────────────────────────────
2:52:56 PM: ​
2:52:56 PM: ❯ Version
2:52:56 PM:   @netlify/build 9.4.0
2:52:56 PM: ​
2:52:56 PM: ❯ Flags
2:52:56 PM:   deployId: 603d70389a53b60007673554
2:52:56 PM:   mode: buildbot
2:52:56 PM: ​
2:52:56 PM: ❯ Current directory
2:52:56 PM:   /opt/build/repo
2:52:56 PM: ​
2:52:56 PM: ❯ Config file
2:52:56 PM:   /opt/build/repo/netlify.toml
2:52:56 PM: ​
2:52:56 PM: ❯ Context
2:52:56 PM:   production
2:52:56 PM: ​
2:52:56 PM: ────────────────────────────────────────────────────────────────
2:52:56 PM:   1. build.command from netlify.toml                            
2:52:56 PM: ────────────────────────────────────────────────────────────────
2:52:56 PM: ​
2:52:56 PM: $ hugo --gc --minify
2:52:56 PM: Start building sites …
2:52:56 PM:                    | EN
2:52:56 PM: -------------------+-----
2:52:56 PM:   Pages            | 23
2:52:56 PM:   Paginator pages  |  0
2:52:56 PM:   Non-page files   |  0
2:52:56 PM:   Static files     | 50
2:52:56 PM:   Processed images |  0
2:52:56 PM:   Aliases          |  9
2:52:56 PM:   Sitemaps         |  1
2:52:56 PM:   Cleaned          |  0
2:52:56 PM: Total in 65 ms
2:52:56 PM: ​
2:52:56 PM: (build.command completed in 119ms)
2:52:56 PM: ​
2:52:56 PM: ────────────────────────────────────────────────────────────────
2:52:56 PM:   2. Functions bundling                                         
2:52:56 PM: ────────────────────────────────────────────────────────────────
2:52:56 PM: ​
2:52:56 PM: No Functions were found in netlify/functions directory
2:52:56 PM: ​
2:52:56 PM: (Functions bundling completed in 15ms)
2:52:56 PM: ​
2:52:56 PM: Creating deploy upload records
2:52:56 PM: ────────────────────────────────────────────────────────────────
2:52:56 PM:   3. Deploy site                                                
2:52:56 PM: ────────────────────────────────────────────────────────────────
2:52:56 PM: ​
2:52:56 PM: Starting to deploy site from 'public'
2:52:56 PM: Creating deploy tree 
2:52:56 PM: 0 new files to upload
2:52:56 PM: 0 new functions to upload
2:52:56 PM: Site deploy was successfully initiated
2:52:56 PM: ​
2:52:56 PM: (Deploy site completed in 131ms)
2:52:56 PM: ​
2:52:56 PM: ────────────────────────────────────────────────────────────────
2:52:56 PM:   Netlify Build Complete                                        
2:52:56 PM: ────────────────────────────────────────────────────────────────
2:52:56 PM: ​
2:52:56 PM: (Netlify Build completed in 320ms)
2:52:56 PM: Caching artifacts
2:52:56 PM: Started saving build plugins
2:52:56 PM: Finished saving build plugins
2:52:56 PM: Started saving pip cache
2:52:56 PM: Starting post processing
2:52:56 PM: Finished saving pip cache
2:52:56 PM: Started saving emacs cask dependencies
2:52:56 PM: Post processing - HTML
2:52:56 PM: Finished saving emacs cask dependencies
2:52:56 PM: Started saving maven dependencies
2:52:56 PM: Finished saving maven dependencies
2:52:56 PM: Started saving boot dependencies
2:52:56 PM: Finished saving boot dependencies
2:52:56 PM: Started saving rust rustup cache
2:52:56 PM: Finished saving rust rustup cache
2:52:56 PM: Started saving go dependencies
2:52:56 PM: Finished saving go dependencies
2:52:56 PM: Build script success
2:52:56 PM: Post processing - header rules
2:52:56 PM: Post processing - redirect rules
2:52:57 PM: Post processing done
2:52:57 PM: Site is live ✨
2:53:11 PM: Finished processing build request in 29.55751538s

The functions don’t go in .netlify/functions folder. That folder is automatically created by Netlify.

You just need to create a folder called functions and use that as your functions folder. The one with .netlify/functions/ would be automatically created by Netlify.

Hey!

When it comes to Go you actually need to put the compiled binary in that folder, I know the documentation is a bit flaky when it comes to this.

There’s an example repo made by Netlify here:

That’s a bit different from the way I usually set things up though, I extracted the way I do it into this repository:

I deployed this to Netlify as can be seen here:

$ curl https://603e05a3059318941b65d64b--netlify-help-golang-lambda.netlify.app/.netlify/functions/test
Hello, World!

A good article about this can be found here

Hope this helps!