- Go 100%
| error.go | ||
| go.mod | ||
| go.sum | ||
| id.go | ||
| id_marshaljson_test.go | ||
| id_string_test.go | ||
| id_unmarshaljson_test.go | ||
| LICENSE | ||
| notification.go | ||
| notification_marshaljson_test.go | ||
| notification_unmarshaljson_test.go | ||
| null.go | ||
| params.go | ||
| README.md | ||
| request.go | ||
| request_marshaljson_test.go | ||
| response.go | ||
| response_marshaljson_test.go | ||
go-jsonrpc2
Package jsonrpc2 provides an implementation of JSON-RPC 2.0, for the Go programming-language (golang).
(The JSON-RPC 2.0 specification is available here: https://www.jsonrpc.org/specification )
From the JSON-RPC 2.0 specification:
JSON-RPC is a stateless, light-weight [client-server based] remote procedure call (RPC) protocol. […] It is transport agnostic in that the concepts can be used within the same process, over sockets, over http, or in many various message passing environments.
It is designed to be simple!
[…]
Since JSON-RPC utilizes JSON, it has the same type system [as JSON].
Documention
Online documentation, which includes examples, can be found at: http://godoc.org/github.com/reiver/go-jsonrpc2
Example
An example JSON-RPC 2.0 request, send from the client to the server, looks like this:
{"jsonrpc": "2.0", "id": 1, "method": "subtract", "params": [42, 23]}
And, an example JSON-RPC 2.0 response, send from the server to the client, looks like this:
{"jsonrpc": "2.0", "id": 1, "result": 19}
(The "jsonrpc" is always set to "2.0".)
(Note that the value of the "id" field is the same in the request and the response.)
Using this package, the request can be represented in Go code as:
import "github.com/reiver/go-jsonrpc2"
// ...
request := jsonrpc2.Request{
ID: IDint64(1),
Method: "subtract",
Params: []int{42, 23},
}
And, the response can be represents in Go code as:
import "github.com/reiver/go-jsonrpc2"
// ...
response := jsonrpc2.Response{
ID: IDint64(1),
Result: 19,
}
Import
To import package jsonrpc2 use import code like the following:
import "github.com/reiver/go-jsonrpc2"
Installation
To install package jsonrpc2 do the following:
GOPROXY=direct go get github.com/reiver/go-jsonrpc2
Author
Package jsonrpc2 was written by Charles Iliya Krempeaux