谷歌云功能-Golag没有找到与名称匹配的功能



我试图通过gitlab CI在GCP上运行我的函数,但它返回以下错误:

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

路径:test/function.go

文件名";function.go";

部署

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")
}

我应该删除中的.mod吗.gcloudignore文件?

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

有人经历过这个问题吗?

您将入口点指定为:

--entry-point=RunUsers

函数声明为:

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

注意大小写中函数名称的差异:runUsersRunUsers

部署中出现问题,中的代码是正确的,并且功能正在中工作

当尝试在本地运行代码时,我遇到了相同的错误:

Serving function: "Execute"2023/02/06 11:57:36 funcframework.Start: no matching function found with name: "Execute"

解决方案需要在我的代码中包括一个func init()(以及cmd/main.go文件(,请参阅文档:

https://github.com/GoogleCloudPlatform/functions-framework-go#quickstart-你好世界在你的本地机器

相关内容

  • 没有找到相关文章

最新更新