Add initial Go CLI skeleton
This commit is contained in:
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user