英文:
gcloud functions deploy go runtime error "undefined: unsafe.Slice; Error ID: 2f5e35a0"
问题
在部署到Google Cloud 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
这是我的命令:
gcloud functions deploy servicename --region=us-central1 --entry-point=gofunctionname --runtime=go116 --source=.
我正在使用vendoring来打包我的依赖项。我已经有一段时间没有更新这个函数了。这是我第一次注意到这个错误。
非常感谢任何帮助。
英文:
While deploying to google cloud function, I am getting this error:
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. It's been a while I have updated this function. And first time I noticed this error.
Any help would be much appreciated.
答案1
得分: 10
根据DazWilkin的建议,unsafe.Slice
是作为Go 1.17的一部分添加的,而GCP Functions目前支持Go 1.16。
我不得不在go.mod
文件中将golang.org/x/sys
模块还原,这对我起作用了。
从
golang.org/x/sys v0.0.0-20221010170243-090e33056c14 // indirect
到
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect
通过这个更改,我能够构建和部署代码到Google Cloud Functions。
英文:
As DazWilkin suggested above, unsafe.Slice
was added as part of Go 1.17 and GCP Functions support Go 1.16 as of now.
I had to revert back the golang.org/x/sys
module in the go.mod
file and it worked for me.
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.
答案2
得分: 1
截至撰写本文时,Google Cloud Functions现在支持Go 1.18和Go 1.19。
将您的项目更新为go119
,您就不应该再遇到这个问题了。例如:
gcloud functions deploy servicename --runtime=go119 --region=us-central1
英文:
As of the time of writing this, Google Cloud Functions now supports Go 1.18 and Go 1.19.
Update your project to go119
and you shouldn't have this issue anymore. For example:
gcloud functions deploy servicename --runtime=go119 --region=us-central1
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论