1package mpv23import (4 "encoding/json"5 "io"6)78const noError = "success"910type response struct {11 Error string `json:"error"`12 Data interface{} `json:"data"`13 ReqID int32 `json:"request_id"`1415 // Additional fields used by observe events16 ID int32 `json:"id"`17 Event string `json:"event"`18 PropertyName string `json:"name"`19}2021type request struct {22 Cmd []interface{} `json:"command"`23 ID int32 `json:"request_id"`24}2526func (r *request) Encode(w io.Writer) error {27 enc := json.NewEncoder(w)2829 err := enc.Encode(r)30 if err != nil {31 return err32 }3334 return nil35}3637func (r *request) String() string {38 data, err := json.Marshal(r)39 if err != nil {40 // This function is primarly intended for debugging41 // purposes and therefore panics on error.42 panic(err)43 }4445 return string(data)46}