简体   繁体   English

gcloud 函数部署 go 运行时错误“undefined: unsafe.Slice; Error ID: 2f5e35a0”

[英]gcloud functions deploy go runtime error "undefined: unsafe.Slice; Error ID: 2f5e35a0"

While deploying to google cloud function, I am getting this error:部署到谷歌云 function 时,出现此错误:

ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Build failed: # projectname/vendor/golang.org/x/sys/unix
src/projectname/vendor/golang.org/x/sys/unix/syscall.go:83:16: undefined: unsafe.Slice
src/projectname/vendor/golang.org/x/sys/unix/syscall_linux.go:2255:9: undefined: unsafe.Slice
src/projectname/vendor/golang.org/x/sys/unix/syscall_unix.go:118:7: undefined: unsafe.Slice
src/projectname/vendor/golang.org/x/sys/unix/sysvshm_unix.go:33:7: undefined: unsafe.Slice; Error ID: 2f5e35a0

Here's my command:这是我的命令:

gcloud functions deploy servicename --region=us-central1 --entry-point=gofunctionname --runtime=go116 --source=.

I am using vendoring to package my dependencies.我正在使用 vendoring 到 package 我的依赖项。 It's been a while I have updated this function. And first time I noticed this error.我更新这个 function 已经有一段时间了。我第一次注意到这个错误。

Any help would be much appreciated.任何帮助将非常感激。

As DazWilkin suggested above, unsafe.Slice was added as part of Go 1.17 and GCP Functions support Go 1.16 as of now.正如 DazWilkin 上面所建议的, unsafe.Slice是作为 Go 1.17 的一部分添加的,GCP 函数目前支持 Go 1.16。

I had to revert back the golang.org/x/sys module in the go.mod file and it worked for me.我不得不还原go.mod文件中的golang.org/x/sys模块,它对我有用。

From

golang.org/x/sys v0.0.0-20221010170243-090e33056c14 // indirect

To

golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect

With this change, I am able to build and deploy the code to Google Cloud Functions.通过此更改,我能够构建代码并将其部署到 Google Cloud Functions。

As of the time of writing this, Google Cloud Functions now supports Go 1.18 and Go 1.19 .截至撰写本文时,Google Cloud Functions 现在支持Go 1.18 和 Go 1.19

Update your project to go119 and you shouldn't have this issue anymore.将您的项目更新为go119 ,您应该不会再遇到此问题。 For example:例如:

gcloud functions deploy servicename --runtime=go119 --region=us-central1 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:(gcloud.functions.deploy)消息=构建失败:function.js 不存在 - ERROR: (gcloud.functions.deploy) message=Build failed: function.js does not exist gcloud 函数部署问题 - gcloud functions deploy issue 错误:(gcloud.beta.functions.deploy)...消息=[调用者没有权限] - ERROR: (gcloud.beta.functions.deploy) ... message=[The caller does not have permission] 如何修复错误:(gcloud.functions.deploy)PERMISSION_DENIED:权限'run.services.setIamPolicy'拒绝资源' - How to fix ERROR: (gcloud.functions.deploy) PERMISSION_DENIED: Permission 'run.services.setIamPolicy' denied on resource ' gcloud app deploy error too many files under.cache - gcloud app deploy error too many files under .cache gcloud 函数部署忽略点文件 - gcloud functions deploy ignores dot-files 使用 gcloud 报告 Stackdriver 错误 - Stackdriver error reporting with gcloud Firebase 云函数部署错误 - 超出配额 - Firebase Cloud Functions Deploy Error - Quota Exceeded Firebase 部署:错误:无法检测函数语言 - Firebase Deploy: Error: Could not detect language for functions at 尝试在 google cloud flex appengine 中安装 wordpress; 在“gcloud app deploy”中出错 - Trying to install wordpress in google cloud flex appengine; getting error in "gcloud app deploy"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM