Simple headless version without any native dependencies. It's just go and can be cross-compiled to any target OS from any other OS.
/cmd/headless-libusb
Headless version with native dependency (libusb) for direct printing over USB.
/cmd/windows-direct
Electron window + Windows syscalls for direct printing on Windows.
After adding libusb I think it's a good time to rethink this approach. Maybe you are using MacOSX and still want to have a electron window and libusb. Currently that is not covered by these 3 packages.
In Go it's possible to activate and deactivate features based on OS or tags that can be specified while building. I think this would be a better solution than separate packages and would allow users to mix and match what they need.
My Idea
Remove /cmd/headless/cmd/headless-libusb and /cmd/windows-direct
The main.go will be moved to /cmd/main.go
Without specifying any tags main.go will be the normal headless version without any native dependencies
On windows the windows direct printing will be automatically enabled because it only requires syscalls and no native dependencies that need to be compiled. So there is no downside to just activating it when OS == windows
Optional Tags
LIBUSB will enable usb printing and require libusb-1.0 to be installed
ELECTRON will enable a electron window where the frontend is shown
Example
headless without libusb or electron window
cd /somewhere/.../snd/cmd
go build
libusb
cd /somewhere/.../snd/cmd
go build -tags="LIBUSB"
libusb + electron
cd /somewhere/.../snd/cmd
go build -tags="LIBUSB ELECTRON"
This also would help to keep it more DRY because the 3 packages currently all contain the same main() function with just minor changes.
I pushed it to a seperate branch so feel free to take a look at it cmd-unify/cmd. If there are no objections I will merge it into master.
Just a little info for anybody that is not familiar with go. The init() function of a file will be executed before the main function. This can be combined with the build tags / constraints to enable or remove stuff depending on the tags or OS.
Currently there is
/cmd/headless
/cmd/headless-libusb
/cmd/windows-direct
After adding libusb I think it's a good time to rethink this approach. Maybe you are using MacOSX and still want to have a electron window and libusb. Currently that is not covered by these 3 packages.
In Go it's possible to activate and deactivate features based on OS or tags that can be specified while building. I think this would be a better solution than separate packages and would allow users to mix and match what they need.
My Idea
/cmd/headless
/cmd/headless-libusb
and/cmd/windows-direct
main.go
will be moved to/cmd/main.go
main.go
will be the normal headless version without any native dependencieswindows
the windows direct printing will be automatically enabled because it only requires syscalls and no native dependencies that need to be compiled. So there is no downside to just activating it when OS ==windows
Optional Tags
LIBUSB
will enable usb printing and require libusb-1.0 to be installedELECTRON
will enable a electron window where the frontend is shownExample
headless without libusb or electron window
libusb
libusb + electron
This also would help to keep it more
DRY
because the 3 packages currently all contain the samemain()
function with just minor changes.I pushed it to a seperate branch so feel free to take a look at it cmd-unify/cmd. If there are no objections I will merge it into
master
.Just a little info for anybody that is not familiar with go. The
init()
function of a file will be executed before the main function. This can be combined with the build tags / constraints to enable or remove stuff depending on the tags or OS.init()
: https://golang.org/doc/effective_go.html#initbuild constraints
: https://golang.org/pkg/go/build/