简体   繁体   中英

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

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.

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.

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 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM