Convert USD to EUR in Go

package mainimport (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {url := "https://api.cloudmersive.com/currency/exchange-rates/convert/%3Cstring%3E/to/%3Cstring%3E"
method := "POST"
payload := strings.NewReader(`"<double>"`)client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Apikey", "YOUR-API-KEY-HERE")
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))
}

--

--

--

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Python Sanic Error: Segmentation fault (core dumped)

How to set or change line endings of a text file in Java

Everything is just a scan way! Integration of Huawei Scan Kit in Books Applications(React Native)

DTO, DAO and MVC Concept

3 Python Packages to Hide Passwords and Secrets From Your Code

3 Solutions to Fix Outlook Error 0X800CC0F

3 Solutions to Fix Outlook Error 0X800CC0F

Scanning an Azure Blob for Viruses in PHP

How to create SEO-friendly URLs in Laravel?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Cloudmersive

Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

More from Medium

Go: validate email address

Rust Web API (Actix) Connect Database (PostgreSQL)

Let’s GO! Part 0: Introduction

How To Upgrade An Indirect Dependency In GoLang