func (id ID) Format(f fmt.State, r rune) {
	numF, strF := `%d`, `%s`
	if r == 'q' {
		numF, strF = `#%d`, `%q`
	}
	switch {
	case id.name != "":
		fmt.Fprintf(f, strF, id.name)
	default:
		fmt.Fprintf(f, numF, id.number)
	}
}
Format writes the ID to the formatter.
If the rune is q the representation is non ambiguous,
string forms are quoted, number forms are preceded by a #
package jsonrpc2
import (
	"encoding/json"
	"fmt"
)
var (
	ErrUnknown = NewError(-32001, "JSON RPC unknown error")
	ErrParse = NewError(-32700, "JSON RPC parse error")
	ErrInvalidRequest = NewError(-32600, "JSON RPC invalid request")
	ErrMethodNotFound = NewError(-32601, "JSON RPC method not found")
	ErrInvalidParams = NewError(-32602, "JSON RPC invalid params")
	ErrInternal = NewError(-32603, "JSON RPC internal error")
	ErrServerOverloaded = NewError(-32000, "JSON RPC overloaded")
)
type wireRequest struct {
	VersionTag wireVersionTag `json:"jsonrpc"`
	Method string `json:"method"`
	Params *json.RawMessage `json:"params,omitempty"`
	ID *ID `json:"id,omitempty"`
}
type wireResponse struct {
	VersionTag wireVersionTag `json:"jsonrpc"`
	Result *json.RawMessage `json:"result,omitempty"`
	Error *wireError `json:"error,omitempty"`
	ID *ID `json:"id,omitempty"`
}
type wireCombined struct {
	VersionTag wireVersionTag   `json:"jsonrpc"`
	ID         *ID              `json:"id,omitempty"`
	Method     string           `json:"method"`
	Params     *json.RawMessage `json:"params,omitempty"`
	Result     *json.RawMessage `json:"result,omitempty"`
	Error      *wireError       `json:"error,omitempty"`
}
type wireError struct {
	Code int64 `json:"code"`
	Message string `json:"message"`
	Data *json.RawMessage `json:"data,omitempty"`
}
type wireVersionTag struct{}
type ID struct {
	name   string
	number int64
}
func NewError(code int64, message string) error {
	return &wireError{
		Code:    code,
		Message: message,
	}
}
func (err *wireError) Error() string {
	return err.Message
}
func (wireVersionTag) MarshalJSON() ([]byte, error) {
	return json.Marshal("2.0")
}
func (wireVersionTag) UnmarshalJSON(data []byte) error {
	version := ""
	if err := json.Unmarshal(data, &version); err != nil {
		return err
	}
	if version != "2.0" {
		return fmt.Errorf("invalid RPC version %v", version)
	}
	return nil
}
func NewIntID(v int64) ID { return ID{number: v} }
func NewStringID(v string) ID { return ID{name: v} }