从今天早上开始,我收到以下错误,但我的代码没有任何改变(只是添加了一个 log.println() ......即使回到以前部署的版本也不能解决问题)
trigger.go(入口点)
// The function that runs with the cloud function itself
func HandleUserCreateEvent(ctx context.Context, e my_project.FirestoreEvent) error {
log.Println("-------------------- oldValue --------------------")
log.Printf("Name: %s\n", e.OldValue.Name)
log.Printf("CreateTime: %v\n", e.OldValue.CreateTime)
log.Printf("Fields: %v\n", e.OldValue.Fields)
log.Printf("UpdateTime: %v\n", e.OldValue.UpdateTime)
log.Println("-------------------- newValue --------------------")
log.Printf("Name: %s\n", e.Value.Name)
log.Printf("CreateTime: %v\n", e.Value.CreateTime)
log.Printf("Fields: %v\n", e.Value.Fields)
log.Printf("UpdateTime: %v\n", e.Value.UpdateTime)
log.Println("-------------------- jsonValue -------------------")
jsonB, _ := json.Marshal(e.Value)
log.Printf("Json: %v\n", string(jsonB))
log.Println("---------------------- DONE ----------------------")
// My code
return nil
deploy.sh(还有一个 deploy.bat 和下面的 sh 脚本一样工作)
#!/usr/bin/env bash
# Deployment automation
name="HandleUserCreateEvent"
projectId="my_project"
collection="UsersCollection"
# Must call go vendor as go modules are ignored
go mod vendor
yes Y | gcloud functions deploy ${name} \
--trigger-event providers/cloud.firestore/eventTypes/document.create \
--trigger-resource "projects/${projectId}/databases/(default)/documents/${collection}/{pushId}" \
--region europe-west1 \
--runtime go113 \
--allow-unauthenticated \
--memory 128
由于这是完美的工作,现在它不再(如前所述,我只是添加了您在上面看到的代码的 jsonValue 部分)
撒科打诨
相关分类