package api import ( "encoding/json" "io" ) type Method string const MethodHello Method = "hello" type Hello struct { Name string `json:"name"` ID string `json:"id"` Version uint `json:"version"` } func (h *Hello) Respond(w io.Writer) error { b, err := json.Marshal(h) if err != nil { return err } _, err = w.Write(b) return err }