Move the gokey cmd main to an importable package#70
Merged
ignatk merged 2 commits intocloudflare:mainfrom Apr 29, 2024
Merged
Conversation
ignatk
approved these changes
Apr 29, 2024
Contributor
ignatk
left a comment
There was a problem hiding this comment.
Thanks for the contribution. FYI I have updated ci workflows and rebased the PR for the CI to run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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-importablemainpackage with an unexportedmainfunction) intocmd/gokey/gokeycmd(as an importablegokeycmdpackage with an exportedMainfunction). 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
gokeyorhelloworld, or symlinks with those names are created, the different sub-commands will be invoked accordingly.Thank you for the consideration.