diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..cd46ca6 --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module github.com/sourcegraph/jsonrpc2 + +go 1.13 + +require github.com/gorilla/websocket v1.4.1 diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..1f9b923 --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM= +github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= diff --git a/handler_with_error.go b/handler_with_error.go index 13ac1c0..51d087b 100644 --- a/handler_with_error.go +++ b/handler_with_error.go @@ -11,7 +11,8 @@ func HandlerWithError(handleFunc func(context.Context, *Conn, *Request) (result return &HandlerWithErrorConfigurer{handleFunc: handleFunc} } -// HandlerWithErrorConfigurer is a handler configuration struct + +// HandlerWithErrorConfigurer is a handler created by HandlerWithError. type HandlerWithErrorConfigurer struct { handleFunc func(context.Context, *Conn, *Request) (result interface{}, err error) suppressErrClosed bool diff --git a/jsonrpc2.go b/jsonrpc2.go index 00f4acf..594f754 100644 --- a/jsonrpc2.go +++ b/jsonrpc2.go @@ -221,8 +221,6 @@ const ( CodeMethodNotFound = -32601 CodeInvalidParams = -32602 CodeInternalError = -32603 - // codeServerErrorStart = -32099 - // codeServerErrorEnd = -32000 ) // Handler handles JSON-RPC requests and notifications. @@ -642,9 +640,8 @@ func (m *anyMessage) UnmarshalJSON(data []byte) error { if len(msgs) == 0 { return errors.New("jsonrpc2: invalid empty batch") } - for i := range msgs { - var m = msgs[i] - if err := checkType(&m); err != nil { + for _, msg := range msgs { + if err := checkType(&msg); err != nil { return err } } @@ -695,10 +692,3 @@ func (v *anyValueWithExplicitNull) UnmarshalJSON(data []byte) error { return json.Unmarshal(data, &v.value) } -/* -var ( - errInvalidRequestJSON = errors.New("jsonrpc2: request must be either a JSON object or JSON array") - errInvalidResponseJSON = errors.New("jsonrpc2: response must be either a JSON object or JSON array") -) -*/ -