How to use usbprinter package in golang?

222 Views Asked by At

Currently, the usb pos printer is connected via usb. I tried various ways to save the data output by the printer to the pc, but all failed. As a last method, I thought of configuring a virtual printer on the pc, saving the data transmitted to the virtual printer to the pc, and then outputting the saved data again.

First, I want to set up a virtual printer.

I found a suitable package for this, but I can't import it. https://pkg.go.dev/chromium.googlesource.com/chromiumos/platform/tast-tests.git/src/chromiumos/tast/local/printing/usbprinter#section-documentation

I ran the below command in the console, but I can't import the package normally.

-MacBookPro printer % go get -u chromium.googlesource.com/chromiumos/platform/tast-tests
go: unrecognized import path "chromium.googlesource.com/chromiumos/platform/tast-tests": parse https://chromium.googlesource.com/chromiumos/platform/tast-tests?go-get=1: no go-import meta tags ()

Since I'm a beginner in golang, I think the repository url is wrong, but I don't know how to use the package normally.

Can you show me a simple example of configuring a virtual printer using that package? Please.

Or, is there a tutorial on how to properly import the google git package? Please give me some advice.

-MacBookPro printer % go get -u chromium.googlesource.com/chromiumos/platform/tast-tests.git/src/chromiumos/tast/local/printing/usbprinter
chromium.googlesource.com/chromiumos/platform/tast-tests.git/src/chromiumos/tast/local/printing/usbprinter imports
        chromiumos/tast/common/testexec: package chromiumos/tast/common/testexec is not in GOROOT (/opt/homebrew/Cellar/go/1.19.3/libexec/src/chromiumos/tast/common/testexec)
chromium.googlesource.com/chromiumos/platform/tast-tests.git/src/chromiumos/tast/local/printing/usbprinter imports
        chromiumos/tast/errors: package chromiumos/tast/errors is not in GOROOT (/opt/homebrew/Cellar/go/1.19.3/libexec/src/chromiumos/tast/errors)
chromium.googlesource.com/chromiumos/platform/tast-tests.git/src/chromiumos/tast/local/printing/usbprinter imports
        chromiumos/tast/local/printing/lp: package chromiumos/tast/local/printing/lp is not in GOROOT (/opt/homebrew/Cellar/go/1.19.3/libexec/src/chromiumos/tast/local/printing/lp)
chromium.googlesource.com/chromiumos/platform/tast-tests.git/src/chromiumos/tast/local/printing/usbprinter imports
        chromiumos/tast/testing: package chromiumos/tast/testing is not in GOROOT (/opt/homebrew/Cellar/go/1.19.3/libexec/src/chromiumos/tast/testing)

I checked the comments and tried to import the package like below, but it returns an error, is there something wrong with the package??

It seems that the manual confirmed that golang does not require path-related settings since version 1.13. What part can I check to solve this problem?

0

There are 0 best solutions below