jsonrpc

package
v1.0.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 11 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package jsonrpc is JSON-RPC 2.0 over a stream, framed as the language server protocol frames it: a Content-Length header, a blank line and the body. The SIML language server and the spell data server both speak it.

Index

Constants

View Source
const (
	CodeParseError       = -32700
	CodeInvalidRequest   = -32600
	CodeMethodNotFound   = -32601
	CodeInvalidParams    = -32602
	CodeInternalError    = -32603
	CodeRequestCancelled = -32800
	CodeContentModified  = -32801
	CodeRequestFailed    = -32803
)

Variables

This section is empty.

Functions

func PathURI

func PathURI(path string) string

The file: URI of a path, as editors write it.

func URIPath

func URIPath(uri string) (string, bool)

The path of a file: URI; false for another scheme. A URI with a host names a UNC path.

Types

type FrameReader

type FrameReader struct {
	// contains filtered or unexported fields
}

func NewFrameReader

func NewFrameReader(in io.Reader) *FrameReader

func (*FrameReader) Read

func (f *FrameReader) Read() ([]byte, error)

The body of the next frame; io.EOF when the stream ends between frames.

type FrameWriter

type FrameWriter struct {
	// contains filtered or unexported fields
}

Writes whole frames, one at a time, from any goroutine.

func NewFrameWriter

func NewFrameWriter(out io.Writer) *FrameWriter

func (*FrameWriter) Notify

func (w *FrameWriter) Notify(method string, params any)

func (*FrameWriter) Request

func (w *FrameWriter) Request(id int, method string, params any)

A request to the other side, whose answer the writer does not wait for.

func (*FrameWriter) Respond

func (w *FrameWriter) Respond(id json.RawMessage, result any, rpcErr *ResponseError)

func (*FrameWriter) Write

func (w *FrameWriter) Write(msg Message)

type Message

type Message struct {
	JSONRPC string          `json:"jsonrpc"`
	ID      json.RawMessage `json:"id,omitempty"`
	Method  string          `json:"method,omitempty"`
	Params  json.RawMessage `json:"params,omitempty"`
	Result  json.RawMessage `json:"result,omitempty"`
	Error   *ResponseError  `json:"error,omitempty"`
}

type ResponseError

type ResponseError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

An error a request answers with.

func (*ResponseError) Error

func (e *ResponseError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL