---
title: Go
slug: brcli-go
docTags: 
createdAt: 2023-03-08T03:28:57.000Z
---

:::CodeblockTabs
```go
package main

import (
 "os/exec"
 . "fmt"
 "runtime"
 "bytes"
 "os"
)

func main() {
	isWindows := runtime.GOOS == "windows"
	exe, shell, flag := "./BarcodeReaderCLI", "sh", "-c"
	if isWindows {
		exe, shell, flag = ".\\BarcodeReaderCLI", "cmd.exe", "/c"
	} 

	args := []string{
		exe,
		"-type=code128",
		"https://wabr.inliteresearch.com/SampleImages/1d.pdf",
		"@./brcli-example.config" // Additional options and sources in configuration file
		}

	cmd := ""
	for _, s := range args {cmd = cmd + s + " "}
	 
    proc := exec.Command(shell, flag, cmd)
	var stdout bytes.Buffer
	var stderr bytes.Buffer
	proc.Stdout = &stdout
	proc.Stderr = &stderr
	proc.Run()
	
	if stdout.Len() > 0 { Print("STDOUT: \n" + stdout.String())}
    if stderr.Len() > 0  { Print("STDERR: \n" + stderr.String())}
}
```

brcli-example.config

```linux
# -silent
-type=code39
# image from URL
https://wabr.inliteresearch.com/SampleImages/1d.pdf
# image from local folder
./images/test.tif
```
:::

