Looking for a tiny go/golang snippet to connect to bitcoin core json rpc I've done it previously in C++ and I'm currently learning go/golang
I'd rather do it &quot;from scratch&quot; 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 (
    "fmt"
    "io/ioutil"
    "net/http"
    "strings"
)

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

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

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