GoDoxy/internal/notif/format.go
Yuzerion 80bc018a7f
feat: custom json marshaling implementation, replace json and yaml library (#89)
* chore: replace gopkg.in/yaml.v3 vs goccy/go-yaml; replace encoding/json with bytedance/sonic

* fix: yaml unmarshal panic

* feat: custom json marshaler implementation

* chore: fix import and err marshal handling

---------

Co-authored-by: yusing <yusing@6uo.me>
2025-04-16 15:02:11 +08:00

27 lines
507 B
Go

package notif
import (
"bytes"
"github.com/yusing/go-proxy/pkg/json"
)
func formatMarkdown(extras LogFields) string {
msg := bytes.NewBufferString("")
for _, field := range extras {
msg.WriteString("#### ")
msg.WriteString(field.Name)
msg.WriteRune('\n')
msg.WriteString(field.Value)
msg.WriteRune('\n')
}
return msg.String()
}
func formatDiscord(extras LogFields) (string, error) {
fields, err := json.Marshal(extras)
if err != nil {
return "", err
}
return string(fields), nil
}