Google cloud函数- Golag未找到名称为的匹配函数

6ie5vjzr  于 2023-02-10  发布在  Go
关注(0)|答案(3)|浏览(147)

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

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

路径:测试/函数. go
文件名"函数. go"
部署
x一个一个一个一个x一个一个二个x
我应该删除.gcloudignore文件中的. mod吗?
格鲁迪戈尔:

# 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

有人经历过这个问题吗?

qvk1mo1f

qvk1mo1f1#

您将入口点指定为:

--entry-point=RunUsers

函数声明为:

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

注意函数名的case的不同:runUsersRunUsers的对比。

ktecyv1j

ktecyv1j2#

部署时出现问题,中的代码正确且功能正常

tjvv9vkg

tjvv9vkg3#

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

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-hello-world-on-your-local-machine

相关问题