DEVELOPERS / GO / ZPL
Print ZPL Labels From Go
Two ways to print labels from Go: raw ZPL over net.Dial to port 9100, or the LabelInn Go SDK — print to any printer from any server, with queueing, status and templates.
conn, err := net.DialTimeout("tcp", "192.168.1.50:9100", 5*time.Second)
if err != nil {
log.Fatal(err)
}
defer conn.Close()
conn.Write([]byte("^XA^FO50,50^A0N,40,40^FDHello from LabelInn^FS^XZ"))THE PROBLEM

You need Go code to put a label on a thermal printer: a shipping label when an order is paid, a product label when a batch is finished. There are two ways to do it. This page shows both, with code you can paste.
01 / GO
The quick way: raw ZPL to port 9100
Zebra printers, and most printers that emulate ZPL, accept raw ZPL on TCP port 9100. If your code runs on the same network as the printer, this is all it takes:
conn, err := net.DialTimeout("tcp", "192.168.1.50:9100", 5*time.Second)
if err != nil {
log.Fatal(err)
}
defer conn.Close()
conn.Write([]byte("^XA^FO50,50^A0N,40,40^FDHello from LabelInn^FS^XZ"))02 / ZPL
Why not just open a socket?
Writing ZPL to port 9100 works on the bench. In production it leaves you with problems the printer will not solve for you:
- Your server has to reach the printer. A cloud-hosted Go app cannot open a socket to a printer on a warehouse LAN without a VPN or port forwarding.
- Nothing tells you it printed. Port 9100 accepts the bytes whether or not the ribbon is out or the head is open.
- Nothing queues. If the printer is off, the job is gone.
- One language per printer. ZPL works on Zebra; TSC wants TSPL, Toshiba wants TPCL.
LabelInn puts a small runtime next to the printer that connects out to the cloud. Your code calls one HTTPS API from anywhere; the job is queued, delivered in the printer's own language, and its status comes back.
go get github.com/labelinn/labelinn-go/v3, one API key, and your Go code prints to any registered printer, anywhere. Get a key →
03 / ZEBRA
Install the SDK
go get github.com/labelinn/labelinn-go/v304 / API
Find the printer
Register the printer once in the LabelInn app on the computer it is connected to. Then list your printers to get the id:
import labelinn "github.com/labelinn/labelinn-go/v3"
client := labelinn.New("sk_live_...")
printers, err := client.Fleet.List(nil)
if err != nil {
log.Fatal(err)
}
for _, p := range printers {
fmt.Println(p.ID, p.Name, p.Status)
}05 / GO
Print ZPL
job, err := client.Print.Create(&labelinn.CreateJobRequest{
PrinterID: "prt_abc123",
PayloadType: "zpl",
PayloadData: "^XA^FO50,50^A0N,40,40^FDHello from LabelInn^FS^XZ",
})
if err != nil {
log.Fatal(err)
}
fmt.Println(job.ID, job.Status)06 / ZPL
Print a designed label with data
Raw ZPL means your code owns the layout. With a template, the label is designed visually in LabelInn and your code sends only the data. Fields fill by name, and LabelInn converts the design to ZPL, TSPL or TPCL for whichever printer you choose.
job, err := client.Print.Create(&labelinn.CreateJobRequest{
PrinterID: "prt_abc123",
PayloadType: "template",
DesignID: "dsg_shipping",
Data: map[string]string{"order_id": "ORD-9876", "customer": "Jane Doe", "barcode": "TR123456789"},
Copies: 2,
})
if err != nil {
log.Fatal(err)
}
fmt.Println(job.ID)07 / ZEBRA
Print many labels in one call
Batch up to 100 jobs per request. Each job is accepted or rejected on its own, so one bad row does not sink the rest.
var jobs []labelinn.CreateJobRequest
for _, sku := range []string{"A-1001", "A-1002", "A-1003"} {
jobs = append(jobs, labelinn.CreateJobRequest{
PrinterID: "prt_abc123", PayloadType: "template",
DesignID: "dsg_product", Data: map[string]string{"sku": sku},
})
}
result, err := client.Print.Batch(jobs)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%d of %d accepted\n", result.Succeeded, result.Total)08 / API
Never print the same label twice
Retries happen: a timeout, a redeploy, a queue redelivery. Send an idempotency key and a repeated call returns the original job instead of printing again.
job, err := client.Print.Create(&labelinn.CreateJobRequest{
PrinterID: "prt_abc123",
PayloadType: "template",
DesignID: "dsg_shipping",
Data: map[string]string{"order_id": "ORD-9876"},
}, labelinn.WithIdempotencyKey("order-ORD-9876-label"))
if err != nil {
log.Fatal(err)
}
fmt.Println(job.ID)Printing through the API is part of the Pro plan, and the free trial includes it. Keys that start with sk_test_ run against a sandbox that never prints, so you can build and test before going live. See pricing.
09 / GO
Same thing, other languages
TESTED
What was run for this page
The snippets on this page were run on 17 October 2026 against a local mock of the API (the official SDK, installed from its package registry) and a local listener standing in for port 9100. They prove the request shape and the code compiles and runs; they do not prove a physical print.
Go 1.23 with go get github.com/labelinn/labelinn-go/v3, which resolved to v3.0.0, the newest tagged release on the Go module proxy on 17 October 2026. result.Succeeded and result.Total read 3 and 3.
| SDK fact | Value (checked 17 October 2026) |
|---|---|
| Module | github.com/labelinn/labelinn-go/v3 (the /v3 suffix is required by Go for major version 3) |
| Go | 1.22 or newer; standard library only |
| Tagged vs source | The repository source carries 3.1.0 features (the LAN Edge client, NewEdge); the proxy served v3.0.0 on this date, so go get does not include them until 3.1.0 is tagged |
| Options | Functional options: labelinn.WithBaseURL(...), labelinn.WithIdempotencyKey(...) |
GO-SPECIFIC
fmt.Fprintf(conn, zpl) eats a percent sign
// wrong: zpl is used as a format string
fmt.Fprintf(conn, zpl)
// right
fmt.Fprint(conn, zpl) // or conn.Write([]byte(zpl))ZPL for a label that says "Sugar 100%" (^FDSugar 100%^FS) came out of Fprintf as ^FDSugar 100%!^(MISSING)FS: Go read %^ as a format verb. go vet flags it, but it only shows up on labels that contain a percent sign. Measured on Go 1.23.
ERRORS
Rate limits and API errors in the SDK
job, err := client.Print.Create(&labelinn.CreateJobRequest{PrinterID: "prt_abc123", PayloadType: "zpl", PayloadData: "^XA^XZ"})
var apiErr *labelinn.Error
if errors.As(err, &apiErr) {
if apiErr.IsRateLimit() {
time.Sleep(time.Duration(apiErr.RetryAfterSeconds) * time.Second)
} else {
log.Printf("%d %s %s", apiErr.StatusCode, apiErr.Code, apiErr.Message)
}
}Tested against a mock returning 429 BURST_RATE_LIMIT (rateLimit=true retryAfter=7) and 400 INVALID_PRINTER (rateLimit=false).
QUESTIONS / FAQ
Frequently asked questions
How do I print a ZPL label from Go?
On the same network, write the ZPL to the printer's TCP port 9100. From anywhere else, install the LabelInn SDK, register the printer once, and call print.create with payload_type "zpl" and the printer id.
Can my cloud-hosted Go app print to a printer in a warehouse?
Yes. The LabelInn runtime next to the printer connects out to LabelInn, so your server calls an HTTPS API and never needs network access to the printer itself.
Does it only work with Zebra printers?
No. Raw ZPL needs a ZPL printer, but templates are converted to the printer's own language, including TSPL for TSC and TPCL for Toshiba.
How do I avoid printing duplicates when a request is retried?
Send an idempotency key with the job. Repeating the call with the same key returns the original job instead of printing again.
Why did my Go label lose text after a percent sign?
fmt.Fprintf(conn, zpl) treats the ZPL as a format string. Use fmt.Fprint or conn.Write([]byte(zpl)).
Which version does go get install for the LabelInn Go SDK?
The newest tagged release of github.com/labelinn/labelinn-go/v3; on 17 October 2026 that was v3.0.0.
KEEP GOING
Related
NEXT STEP / LABELINN
Print from Go without touching a printer driver
Get an API key, register a printer, and send your first label in minutes. · Official SDK · ZPL or visual templates · Queue, status and retries handled