chore: 初始化仓库,导入项目基线代码
Academy v0.8.3 完整代码基线:Go 后端(internal/cmd/cli/mcp-server/docreader)、 Vue 前端(frontend)、数据库迁移(migrations)、部署编排(docker/helm/deploy)与文档。 今日开发的培训推送管理改动随后单独提交。
This commit is contained in:
commit
7ec21f35b0
5767 files changed
+1436788
No files matched your search
@@ -0,0 +1,25 @@
|
||||
package format
|
||||
|
||||
import (
|
||||
"io"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
// WriteNDJSON serializes v as NDJSON: one JSON value per line, '\n' terminated.
|
||||
// If v is a slice or array, each element gets its own line; otherwise v is
|
||||
// emitted as a single line. Per http://ndjson.org.
|
||||
//
|
||||
// HTML escaping is disabled (via WriteJSON) so '<', '>', '&' stay literal —
|
||||
// cleaner for agent stream-parsers that don't need HTML-safe output.
|
||||
func WriteNDJSON(w io.Writer, v any) error {
|
||||
rv := reflect.ValueOf(v)
|
||||
if rv.IsValid() && (rv.Kind() == reflect.Slice || rv.Kind() == reflect.Array) {
|
||||
for i := 0; i < rv.Len(); i++ {
|
||||
if err := WriteJSON(w, rv.Index(i).Interface()); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return WriteJSON(w, v)
|
||||
}
|
||||
Reference in new issue
Block a user