{"id":15998257,"url":"https://github.com/yushulx/gobarcodeqrsdk","last_synced_at":"2025-12-15T20:51:22.980Z","repository":{"id":57567677,"uuid":"46245448","full_name":"yushulx/goBarcodeQrSDK","owner":"yushulx","description":"Golang barcode detection module based on Dynamsoft C/C++ Barcode SDK","archived":false,"fork":false,"pushed_at":"2024-03-21T08:26:45.000Z","size":85088,"stargazers_count":14,"open_issues_count":0,"forks_count":2,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-07-26T07:44:26.501Z","etag":null,"topics":["barcode","c","code39","cpp","docker","ean13","golang","pdf417","qrcode"],"latest_commit_sha":null,"homepage":"https://www.dynamsoft.com/codepool/golang-barcode-qr-code-reader.html","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yushulx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-11-16T01:49:26.000Z","updated_at":"2025-07-12T09:18:37.000Z","dependencies_parsed_at":"2024-03-21T09:58:41.479Z","dependency_job_id":"73542164-65d1-4069-987f-c370ec6eee2a","html_url":"https://github.com/yushulx/goBarcodeQrSDK","commit_stats":null,"previous_names":["dynamsoftsamples/go-barcode-reader","dynamsoft-dbr/go-barcode-reader"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/yushulx/goBarcodeQrSDK","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yushulx%2FgoBarcodeQrSDK","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yushulx%2FgoBarcodeQrSDK/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yushulx%2FgoBarcodeQrSDK/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yushulx%2FgoBarcodeQrSDK/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yushulx","download_url":"https://codeload.github.com/yushulx/goBarcodeQrSDK/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yushulx%2FgoBarcodeQrSDK/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268670461,"owners_count":24287995,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-04T02:00:09.867Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["barcode","c","code39","cpp","docker","ean13","golang","pdf417","qrcode"],"created_at":"2024-10-08T08:08:19.479Z","updated_at":"2025-12-15T20:51:22.973Z","avatar_url":"https://github.com/yushulx.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Golang Barcode QR Code Reader\n\n[![Cross-Platform Build](https://github.com/yushulx/goBarcodeQrSDK/actions/workflows/build.yml/badge.svg)](https://github.com/yushulx/goBarcodeQrSDK/actions/workflows/build.yml)\n[![Test PR](https://github.com/yushulx/goBarcodeQrSDK/actions/workflows/test-pr.yml/badge.svg)](https://github.com/yushulx/goBarcodeQrSDK/actions/workflows/test-pr.yml)\n[![Go Report Card](https://goreportcard.com/badge/github.com/yushulx/goBarcodeQrSDK)](https://goreportcard.com/report/github.com/yushulx/goBarcodeQrSDK/v2)\n\nThis project serves as a Golang wrapper for the [Dynamsoft Barcode Reader C++ SDK](https://www.dynamsoft.com/barcode-reader/sdk-desktop-server/). With this module, you can efficiently read various types of barcodes and symbols, including QR Codes (and Micro QR Codes), Data Matrix, PDF417 (and Micro PDF417), Aztec Code, MaxiCode (modes 2-5), and DotCode from images and PDF files.\n\n## Prerequisites\n* [Go](https://go.dev/dl/)\n* [30-day free trial license](https://www.dynamsoft.com/customer/license/trialLicense/?product=dcv\u0026package=cross-platform) for Dynamsoft Barcode Reader.\n\n## Building the Bridge Library\n\n**Important**: Before using this Go module, you must build the C++ bridge library that connects Go to the Dynamsoft Barcode Reader SDK. This bridge is essential for the module to function.\n\n### Prerequisites for Building\n- **Windows**: Visual Studio 2022 with C++ build tools, CMake\n- **Linux**: GCC/G++, CMake, build-essential\n- **macOS**: Xcode Command Line Tools, CMake\n\n### Quick Build (All Platforms)\nUse the provided build scripts to automatically build the bridge library:\n\n```bash\n# Windows (PowerShell)\n.\\scripts\\build.ps1\n\n# Linux\n./scripts/build.sh\n\n# macOS (single architecture - current system)\n./scripts/build_macos.sh\n\n# macOS Universal Binary (ARM64 + x86_64)\n./scripts/build_macos_universal.sh\n```\n\n**Note for macOS**: Use `build_macos_universal.sh` to create a universal binary that works on both Apple Silicon (M1/M2/M3) and Intel Macs. This is recommended for distribution.\n\n### Manual Build Process\nIf you prefer to build manually or need to customize the build:\n\n1. **Create build directory:**\n   ```bash\n   mkdir build\n   cd build\n   ```\n\n2. **Configure with CMake:**\n   ```bash\n   # Windows\n   cmake .. -G \"Visual Studio 17 2022\" -A x64\n   \n   # Linux/macOS\n   cmake .. -DCMAKE_BUILD_TYPE=Release\n   ```\n\n3. **Build the library:**\n   ```bash\n   # Windows\n   cmake --build . --config Release\n   \n   # Linux/macOS\n   cmake --build . --config Release\n   ```\n\n4. **Verify build artifacts:**\n   - **Windows**: `dcv/lib/win/Release/bridge.dll`\n   - **Linux**: `dcv/lib/linux/libbridge.so`\n   - **macOS**: `dcv/lib/mac/libbridge.dylib`\n\n## Supported Platforms\n- Windows (x64)\n- Linux (x64)\n- macOS (x64/ARM64) - Universal binary support for both Intel and Apple Silicon Macs\n\n## Test the Module\n\n```bash\n# Windows\n.\\run_windows_test.ps1\n\n# Linux\n./run_linux_test.sh\n\n## mac\nchmod +x run_mac_test.sh\nsudo ./run_mac_test.sh\n```\n\n## How to Use the Go Module \n\n**Before using the module, make sure you have built the bridge library as described in the \"Building the Bridge Library\" section above.**\n\n1. Download the Go module:\n\n\t```bash\n\tgo get github.com/yushulx/goBarcodeQrSDK\n\t```\n\n2. Import the package in your Go file:\n\n\t```go\n\timport (\n\t\t\"github.com/yushulx/goBarcodeQrSDK\"\n\t)\n\t```\n3. Specify the dynamic library path at runtime before running Go apps.\n\n\t- **Windows**\n\n\t\t```bash\n\t\t$originalPath = $env:PATH\n\n\t\t# Get the GOPATH\n\t\t$GOPATH = $(go env GOPATH)\n\n\t\t# Find the path to the shared libraries\n\t\t$PACKAGE_PATH = Get-ChildItem -Path \"$GOPATH\\pkg\\mod\\github.com\\yushulx\" -Directory | Sort-Object LastWriteTime -Descending | Select-Object -First 1 -ExpandProperty FullName\n\t\tWrite-Host \"PACKAGE_PATH set to $PACKAGE_PATH\"\n\t\t$LIBRARY_PATH = \"$PACKAGE_PATH\\lib\\windows\"\n\n\t\tWrite-Host \"LIBRARY_PATH set to $LIBRARY_PATH\"\n\t\t# Update PATH to include the assembly path\n\t\t$env:PATH = \"$LIBRARY_PATH;\" + $env:PATH\n\t\t# Write-Host \"PATH set to $($env:PATH)\"\n\n\t\t# Run your Go application\n\t\tgo run test.go test.png\n\n\t\t$env:PATH = $originalPath\n\t\t```\n\n\t- **Linux**\n\n\t\t```bash\n\t\t#!/bin/bash\n\n\t\t# Save the original PATH\n\t\toriginalPath=$LD_LIBRARY_PATH\n\n\t\t# Get the GOPATH\n\t\tGOPATH=$(go env GOPATH)\n\n\t\t# Find the path to the shared libraries\n\t\tPACKAGE_PATH=$(find \"$GOPATH/pkg/mod/github.com/yushulx\" -mindepth 1 -maxdepth 1 -type d | sort -r | head -n 1)\n\t\techo \"PACKAGE_PATH set to $PACKAGE_PATH\"\n\t\tLIBRARY_PATH=\"$PACKAGE_PATH/lib/linux\"\n\n\t\techo \"LIBRARY_PATH set to $LIBRARY_PATH\"\n\n\t\texport LD_LIBRARY_PATH=\"$LIBRARY_PATH:$originalPath\"\n\n\t\t# Run your Go application\n\t\tgo run test.go test.png\n\n\t\t# Restore the original PATH\n\t\texport LD_LIBRARY_PATH=$originalPath\n\t\t```\n\t\t\n\t- **macOS**\n\n\t\t```bash\n\t\t#!/bin/bash\n\n\t\t# Save the original PATH\n\t\toriginalPath=$LD_LIBRARY_PATH\n\n\t\t# Get the GOPATH\n\t\tGOPATH=$(go env GOPATH)\n\n\t\t# Find the path to the shared libraries\n\t\tPACKAGE_PATH=$(find \"$GOPATH/pkg/mod/github.com/yushulx\" -mindepth 1 -maxdepth 1 -type d | sort -r | head -n 1)\n\t\techo \"PACKAGE_PATH set to $PACKAGE_PATH\"\n\t\tRPATH=\"$PACKAGE_PATH/lib/mac\"\n\n\t\techo \"LIBRARY_PATH set to $LIBRARY_PATH\"\n\n\t\tTARGET=\"testapp\"\n\n\t\tgo build -o $TARGET\n\n\t\tif ! otool -l $TARGET | grep -q $RPATH; then\n\t\t\techo \"Adding rpath $RPATH to $TARGET\"\n\t\t\tinstall_name_tool -add_rpath $RPATH $TARGET\n\t\telse\n\t\t\techo \"RPATH $RPATH already exists in $TARGET\"\n\t\tfi\n\n\t\t./$TARGET test.png\n\n\t\trm ./$TARGET\n\t\t```\n\n## Quick Start\nSet the license key within the `InitLicense()` function, and replace the `image-file` with the path of the image file you wish to decode.\n\n**Note**: This SDK supports multi-page documents (PDF, TIFF). Each barcode result includes a `PageId` field indicating which page the barcode was found on.\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"time\"\n\n\t\"github.com/yushulx/goBarcodeQrSDK\"\n)\n\nfunc main() {\n\t// Initialize license\n\tret, errMsg := goBarcodeQrSDK.InitLicense(\"LICENSE-KEY\")\n\tif ret != 0 {\n\t\tfmt.Printf(\"License initialization failed: %d, %s\\n\", ret, errMsg)\n\t}\n\n\t// Create barcode reader\n\tobj := goBarcodeQrSDK.CreateBarcodeReader()\n\tdefer goBarcodeQrSDK.DestroyBarcodeReader(obj)\n\n\t// Load template (optional)\n\ttemplateData, err := os.ReadFile(\"template.json\")\n\tif err != nil {\n\t\tfmt.Printf(\"Failed to read template.json: %v\\n\", err)\n\t} else {\n\t\tret, errMsg := obj.SetParameters(string(templateData))\n\t\tif ret != 0 {\n\t\t\tfmt.Printf(\"SetParameters failed: %d, %s\\n\", ret, errMsg)\n\t\t}\n\t}\n\n\t// Decode barcodes from file - NEW API follows Go conventions\n\tstartTime := time.Now()\n\tbarcodes, err := obj.DecodeFile(\"image-file\")\n\telapsed := time.Since(startTime)\n\tfmt.Println(\"DecodeFile() time cost:\", elapsed)\n\n\tif err != nil {\n\t\t// Error might contain warnings, but barcodes could still be found\n\t\tfmt.Printf(\"DecodeFile warning/error: %v\\n\", err)\n\t\tif len(barcodes) == 0 {\n\t\t\tfmt.Println(\"No barcodes found\")\n\t\t\treturn\n\t\t}\n\t\tfmt.Printf(\"Found %d barcodes despite warning\\n\", len(barcodes))\n\t}\n\n\t// Process results\n\tfor i, barcode := range barcodes {\n\t\tfmt.Printf(\"\\nBarcode %d:\\n\", i+1)\n\t\tfmt.Printf(\"  Page ID: %d\\n\", barcode.PageId)  // Shows which page the barcode was found on\n\t\tfmt.Printf(\"  Text: %s\\n\", barcode.Text)\n\t\tfmt.Printf(\"  Format: %s\\n\", barcode.Format)\n\t\tfmt.Printf(\"  Coordinates: (%d,%d) (%d,%d) (%d,%d) (%d,%d)\\n\",\n\t\t\tbarcode.X1, barcode.Y1, barcode.X2, barcode.Y2,\n\t\t\tbarcode.X3, barcode.Y3, barcode.X4, barcode.Y4)\n\t}\n\n\t// Alternative: Decode from memory\n\timageData, err := os.ReadFile(\"image-file\")\n\tif err == nil {\n\t\tbarcodes, err = obj.DecodeStream(imageData)\n\t\tif err != nil {\n\t\t\tfmt.Printf(\"DecodeStream error: %v\\n\", err)\n\t\t} else {\n\t\t\tfmt.Printf(\"DecodeStream found %d barcodes\\n\", len(barcodes))\n\t\t}\n\t}\n}\n\n``` \n\n## 📚 API Reference\n\n### Core Functions\n```go\n// License management\nret, errMsg := goBarcodeQrSDK.InitLicense(\"LICENSE-KEY\")\n\n// Reader lifecycle\nreader := goBarcodeQrSDK.CreateBarcodeReader()\ngoBarcodeQrSDK.DestroyBarcodeReader(reader)\n\n// Get SDK version\nversion := goBarcodeQrSDK.GetVersion()\n```\n\n### Configuration\n```go\n// Load settings from JSON string\nret, errMsg := reader.SetParameters(jsonString)\n\n// Load settings from file\nret, errMsg := reader.LoadTemplateFile(\"template.json\")\n```\n\n### Barcode Detection\n```go\n// Decode from file\nbarcodes, err := reader.DecodeFile(\"image.png\")\n\n// Decode from memory buffer \nbarcodes, err := reader.DecodeStream(imageData)\n```\n\n### Barcode Result Structure\n```go\ntype Barcode struct {\n    Text   string  // Decoded text content\n    Format string  // Barcode format (QR_CODE, CODE_128, etc.)\n    X1, Y1 int     // Top-left corner\n    X2, Y2 int     // Top-right corner  \n    X3, Y3 int     // Bottom-right corner\n    X4, Y4 int     // Bottom-left corner\n    PageId int     // Page number (for multi-page documents)\n}\n```\n\n## Example\n- [Command-line](https://github.com/yushulx/goBarcodeQrSDK/tree/main/example/command-line)\n- [Web](https://github.com/yushulx/goBarcodeQrSDK/tree/main/example/web)\n\n\n## Docker Build\n- Build and run barcode QR code reader in Docker:\n\n    ```bash\n    docker build -t golang-barcode-qr-reader .\n    docker run -it --rm golang-barcode-qr-reader\n    ```\n- Read barcode and QR code from a local image file:\n\n    ```bash\n    docker run -it --rm -v \u003cimage-folder\u003e:/app golang-barcode-qr-reader reader /app/\u003cimage-file\u003e \u003clicense-key\u003e \u003ctemplate-file\u003e\n    ```\n\n## Docker Usage\n[https://hub.docker.com/repository/docker/yushulx/golang-barcode-qr-reader](https://hub.docker.com/repository/docker/yushulx/golang-barcode-qr-reader)\n\n ```bash\ndocker run -it --rm -v \u003cimage-folder\u003e:/app yushulx/golang-barcode-qr-reader:latest reader /app/\u003cimage-file\u003e \u003clicense-key\u003e \u003ctemplate-file\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyushulx%2Fgobarcodeqrsdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyushulx%2Fgobarcodeqrsdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyushulx%2Fgobarcodeqrsdk/lists"}