Barcode Reader CLI
Integration
Go
Go
brcli-example.config
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())}
}