How to Create an EAN-8 Barcode as a PNG File using Go

Cloudmersive
2 min readDec 9, 2022

--

Packing & shipping compact products in Europe? You’re going to need a lot of EAN-8 barcodes. Thankfully, generating new barcodes is easy via the Cloudmersive Barcode API endpoint: our EAN-8 Generation API will create a PNG file corresponding to your EAN-8 barcode values.

You can easily take advantage of this API by simply copying & pasting the below code examples (provided here in Go, but also available in several additional programming languages here) into your environment and authenticating the service with a Cloudmersive API key. Registering a free account on our website will provide you with a free-tier API key (which provides a limit of 800 API calls per month & no additional commitments upon reaching that limit), and you can easily scale your operation by choosing from a variety of enterprise level accounts if the need arises.

package main

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

func main() {

url := "https://api.cloudmersive.com/barcode/generate/ean-8"
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))
}

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet