Generate a UPC-A Barcode as a PNG File in Go

Depending on your location & business sector, you’ll need a different type of barcode for your products. Take advantage of our Barcode API to generate several common barcode types as 1D PNG images. Below, sample code in Go is included for connecting to our UPC-A generating iteration, copied directly from the Cloudmersive API Console. If you’re using a different language, follow the link and find code in the programming language of your choice.

Otherwise, copy & paste the following:

package mainimport (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {url := "https://api.cloudmersive.com/barcode/generate/upc-a"
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))
}

If you don’t currently have a Cloudmersive API key, head to our website (www.cloudmersive.com) where you can create a free account with zero commitments and receive 800 API calls per month.

--

--

--

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

How to convert any Document File into PNG Array in Python

So you got a circular import in Python.

How I Implemented Realtime Search In React Using Hooks

Postgres SQL installation with master and slave configuration

How to insert an image into a Word DOCX document in Python

Open Sourcing Atlas

How to Create a Hypnogram in Swift?

Building sqlproj projects in Visual Studio Code with dotnet

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

How to Normalize Image Rotation and Remove EXIF Rotation Data in Go

Golang language variable declaration methods and use scenarios

Go — pointers (basics)

GoFrame 101: Static file handler with Web UI