Google cloud Function - Golag no matching function found with name

Viewed 56

I'm trying to run my function on GCP via gitlab CI, but it returns the following error:

Function failed to start: no matching function found with name: "RunUsers"

path: test/function.go

file name "function.go"

deploy

gcloud functions deploy test  
        --runtime=go116
        --entry-point=RunUsers
        --region=us-east1
        --source=.
        --trigger-http
package function

import (
    "io"
    "net/http"

    "github.com/GoogleCloudPlatform/functions-framework-go/functions"

    _ "github.com/GoogleCloudPlatform/functions-framework-go/funcframework"
)

func init() {
    functions.HTTP("RunUsers", RunUsers)
}

func RunUsers(w http.ResponseWriter, r *http.Request) {
    io.WriteString(w, "OK")
}

Should I remove .mod in .gcloudignore file?

gcloudignore:

# This file specifies files that are *not* uploaded to Google Cloud
# using gcloud. It follows the same syntax as .gitignore, with the addition of
# "#!include" directives (which insert the entries of the given .gitignore-style
# file at that point).
#
# For more information, run:
#   $ gcloud topic gcloudignore
#
.gcloudignore
# If you would like to upload your .git directory, .gitignore file or files
# from your .gitignore file, remove the corresponding line
# below:
.git
.gitignore

tests/
README.md
Makefile
env/
*.json
sonar-project.properties
.gitlab-ci.yml
cmd/
*.mod

Has anyone gone through this problem?

2 Answers

You are specifying the entrypoint as:

--entry-point=RunUsers

The function declaration is:

func runUsers(w http.ResponseWriter, r *http.Request)

Notice the difference in case for the function names: runUsers versus RunUsers.

The problem occurred in the deploy, the code in was correct and the function working

Related