[英]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.