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.