fmt.Printlnfmt.Sprintfpackage mainimport ("context""fmt""github.com/tencentyun/scf-go-lib/cloudfunction")type DefineEvent struct {// test event defineKey1 string `json:"key1"`Key2 string `json:"key2"`}func hello(ctx context.Context, event DefineEvent) (string, error) {fmt.Println("key1:", event.Key1)fmt.Println("key2:", event.Key2)return fmt.Sprintf("Hello %s!", event.Key1), nil}func main() {// Make the handler available for Remote Procedure Call by Cloud Functioncloudfunction.Start(hello)}
SCF_Message field when it is delivered to CLS. For descriptions of CLS fields, see Log Delivery Configuration.SCF_CustomKey: SCF, add a key-value index to the log topic for SCF log delivery as instructed in Configuring Indexes.SCF_LogTopic_) does not support modifying the index configuration. You need to set the destination topic to custom delivery first and then update the log topic's index configuration.field:value format. Only top-level field:value pairs where the value is numeric or a string are parsed; other types are ignored.package mainimport ("context""fmt""github.com/tencentyun/scf-go-lib/cloudfunction")type DefineEvent struct {Key1 string `json:"key1"`Key2 string `json:"key2"`}func hello(ctx context.Context, event DefineEvent) (string, error) {m := map[string]string{"key1": "test value 1", "key2": "test value 2"}data, _ := json.Marshal(m)fmt.Println(string(data))return fmt.Sprintf("hello world"), nil}func main() {cloudfunction.Start(hello)}

key1 field in the log query as shown below:

Feedback