Barcode Reader CLI
Integration
Go
Go
brcli-example.config
1package main
2
3import (
4 "os/exec"
5 . "fmt"
6 "runtime"
7 "bytes"
8 "os"
9)
10
11func main() {
12 isWindows := runtime.GOOS == "windows"
13 exe, shell, flag := "./BarcodeReaderCLI", "sh", "-c"
14 if isWindows {
15 exe, shell, flag = ".\\BarcodeReaderCLI", "cmd.exe", "/c"
16 }
17
18 args := []string{
19 exe,
20 "-type=code128",
21 "https://wabr.inliteresearch.com/SampleImages/1d.pdf",
22 "@./brcli-example.config" // Additional options and sources in configuration file
23 }
24
25 cmd := ""
26 for _, s := range args {cmd = cmd + s + " "}
27
28 proc := exec.Command(shell, flag, cmd)
29 var stdout bytes.Buffer
30 var stderr bytes.Buffer
31 proc.Stdout = &stdout
32 proc.Stderr = &stderr
33 proc.Run()
34
35 if stdout.Len() > 0 { Print("STDOUT: \n" + stdout.String())}
36 if stderr.Len() > 0 { Print("STDERR: \n" + stderr.String())}
37}