Snippets Collections
package main

import (
"fmt"
"net/http"
"io/ioutil"
)

func main() {
    url := "https://api.currencyapi.com/v3/latest"
    method := "GET"

    client := &http.Client {
}
req, err := http.NewRequest(method, url, nil)

if err != nil {
    fmt.Println(err)
    return
}
req.Header.Add("apikey", "YOUR-API-KEY")

res, err := client.Do(req)
if err != nil {
    fmt.Println(err)
    return
}
defer res.Body.Close()

body, err := ioutil.ReadAll(res.Body)
if err != nil {
    fmt.Println(err)
    return
}
fmt.Println(string(body))
}
star

Tue Aug 08 2023 08:07:35 GMT+0000 (Coordinated Universal Time) https://currencyapi.com/docs/examples/go-currency-converter

#go #currencyconverter #exchangerates #currency #api

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension