Add initial Go CLI skeleton

This commit is contained in:
2026-03-19 02:55:41 +08:00
parent 84bd4fd9a7
commit 7b35f4dc5f
17 changed files with 536 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
package protocol
import (
"encoding/json"
"io"
)
type Success struct {
OK bool `json:"ok"`
Command string `json:"command"`
Data map[string]any `json:"data,omitempty"`
}
type Error struct {
OK bool `json:"ok"`
Error ErrorPayload `json:"error"`
}
type ErrorPayload struct {
Code string `json:"code"`
Message string `json:"message"`
}
func WriteJSON(w io.Writer, v any) error {
enc := json.NewEncoder(w)
enc.SetIndent("", " ")
return enc.Encode(v)
}