Golang module for working with a barcode scanner
You must first install libusb-1.0. This is pretty straightforward on linux. The cgo package should be able to find it if you install it in the default manner or use your distribution's package manager. For Ubuntu:
$ sudo apt-get install libusb-1.0-0-dev
You may need to grant the current user access to the USB device. This is usually done by adding a file to /etc/udev/rules.d called 50-usb-scale.conf and contents like this:
SUBSYSTEM=="usb", ATTR{idVendor}=="HEX1", ATTR{idProduct}=="HEX2", MODE="0666"
Where HEX1
and HEX2
are replaced by the Vendor and Product ID respectively.
Instead, to match the interface type, you can try replacing ATTR{idVendor}=="HEX1", ATTR{idProduct}=="HEX2" with a match for bInterfaceClass
equal to 03 (HID):
SUBSYSTEM=="usb", ATTR{bInterfaceClass}=="03", MODE="0666"
Then apply udev rules and reboot the platform:
$ sudo udevadm control --reload-rules && udevadm trigger