Go
Control Rclone from Go using the remote control HTTP API or librclone.
Go developers have the unique advantage of being able to use librclone directly, which embeds Rclone as a library.
However, if you need to communicate with a separate Rclone process, the HTTP API works well too.
Usage
package main
import (
"fmt"
"io"
"log"
"net/http"
)
func main() {
resp, err := http.Get("http://localhost:5572/")
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(body))
}resty wraps the same request in a client object and returns the body through response.String(), which removes the manual body reading and closing:
package main
import (
"fmt"
"log"
"github.com/go-resty/resty/v2"
)
func main() {
client := resty.New()
response, err := client.R().Get("http://localhost:5572/")
if err != nil {
log.Fatal(err)
}
fmt.Println(response.String())
}How is this guide?