产品动态
产品公告
fmt.Printlnfmt.Sprintf 类似方法package 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_CustomKey:SCF,请参考 日志服务索引配置 为函数日志投递的日志主题添加键值索引。SCF_LogTopic_ 为前缀命名)不支持修改索引配置。请将函数日志投递主题设置为 自定义投递 后再更新日志主题索引配置。字段:值的方式进行投递。JSON 内容的解析仅能解析第一层的值类型为数值和文本类型的字段:值,其他类型的将被忽略。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字段。如下图所示:

文档反馈