I've done it previously in C++ and I'm currently learning go/golang

I'd rather do it "from scratch" rather than trust a third party's library

Just a call from golang for a json-rpc call to getrpcinfo would be enough to get me moving!

My search so far has only led to entire libraries and applications


Ah... got there myself taking things from multiple sources!

Here's the code snippet:

package main

import (

func main() {
    testRequest := `{"jsonrpc": "1.0", "id":"", "method": "getrpcinfo", "params": []}`

    req, _ := http.NewRequest("POST", "", strings.NewReader(testRequest))
    req.SetBasicAuth("", "notmypassword")
    req.Header.Add("content-type", "text/plain;")

    res, e := http.DefaultClient.Do(req)
    if e != nil {
    } else {
        defer res.Body.Close()
        body, _ := ioutil.ReadAll(res.Body)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.