Move the gokey cmd main to an importable package #70
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Thank you for this great utility! It is so handy in fact that I would love to be able to bundle it into other programs. To this end, this PR lifts the contents of
cmd/gokey
(a non-importablemain
package with an unexportedmain
function) intocmd/gokey/gokeycmd
(as an importablegokeycmd
package with an exportedMain
function). This enables the gokey cmd main to be imported into other single executable binary, multiple use Go programs.How exactly these bundled programs are invoked will vary, but the Busybox-style approach uses multiple symlinks pointing to a common executable, with the symlink name indicating which subprogram should be run.
For example, consider
multicmd.go
:If this program is compiled, and either the executable is renamed to
gokey
orhelloworld
, or symlinks with those names are created, the different sub-commands will be invoked accordingly.Thank you for the consideration.