refactor: improve binding, performance, and type safety

- Implement ShouldBind with support for JSON, Form, WANF, and GOB formats
- Add ShouldBindForm, ShouldBindGOB, and helper functions for form binding
- Use fmt.Appendf instead of fmt.Sprintf for better performance
- Replace interface{} with any for modern Go style
- Use maps.Copy for cleaner header copying
- Update strings.SplitSeq to use range over strings.Seq
- Remove deprecated placeholder comments and add proper implementations
- Fix reflect.Pointer usage for Go 1.22+ compatibility
This commit is contained in:
WJQSERVER 2026-03-17 12:02:49 +08:00
parent 9e3e43bf88
commit c4c0160b5f
6 changed files with 187 additions and 36 deletions

4
sse.go
View file

@ -40,8 +40,8 @@ func (e *Event) Render(w io.Writer) error {
buf.WriteString("\n")
}
if len(e.Data) > 0 {
lines := strings.Split(e.Data, "\n")
for _, line := range lines {
lines := strings.SplitSeq(e.Data, "\n")
for line := range lines {
buf.WriteString("data: ")
buf.WriteString(line)
buf.WriteString("\n")