How to Lookup an EAN Barcode Value & Return Product Data Using Go

Many European retail products are identifiable by their EAN barcode values (most often 8 or 13 digits long). Easily incorporate the EAN barcode lookup iteration of our Barcode API into your project with code samples in Go copied below for your convenience. Before you get started, make sure you have a Cloudmersive API key handy — you can easily get one by creating a free account on our website (www.cloudmersive.com). That’ll also grant you 800 monthly API calls with access to dozens of other useful APIs on the Cloudmersive API Console.

Incorporate the below code into your Go project and incorporate the EAN value where indicated:

package mainimport (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {url := "https://api.cloudmersive.com/barcode/lookup/ean"
method := "POST"
payload := strings.NewReader("0=%3C&1=s&2=t&3=r&4=i&5=n&6=g&7=%3E")client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
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))
}

--

--

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.