Closed JeremyRand closed 5 years ago
If there are useful bits here they should probably move to https://github.com/miekg/dns/tree/master/dnsutil
What bits are useful?
Basically I'd like an API that's equivalent to the command-line API in q
, but as a Go function rather than a command-line tool, with function args instead of command-line flags, and with machine-readable return values instead of stdout/stderr output.
[ Quoting notifications@github.com in "Re: [miekg/exdns] Splitting q into ..." ]
Basically I'd like an API that's equivalent to the command-line API in
q
, but as a Go function rather than a command-line tool, with function args instead of command-line flags, and with machine-readable return values instead of stdout/stderr output.
I don't think that should be added in this repo, as this is just examples. For miekg/dns is also not applicable as it's too high level.
Okay. I guess I'll look into making a library fork of q
, then. That's why it's open-source after all. :)
For anyone curious who's running across this issue, I've created a library fork of q
. https://github.com/namecoin/qlib Very rough around the edges, but works for my use cases.
The
q
example is really nice, and I've wanted to use similar logic in a few of my projects (so that my own code can stick to a nice high-level API for DNS queries without re-implementing lots of DNS logic), but unfortunately since all of theq
code is in themain
package, it can't be used as a library. My initial workaround was just to copy and paste theq
code into my own projects and make changes as needed, but this doesn't exactly scale well.Would a PR be accepted that splits
q
into a library (which has all the code except for theflag
stuff and the stdout/stderr formatting, and renamesmain()
to a public function that accepts the args that are currently handled by globalflag
variables) and an executable (which has all theflag
and stdout/stderr formatting code and adds a simplemain()
function that calls the library using theflag
global variables as args)?(Alternatively, if a library that's similarly flexible and user-friendly as the
q
example is already exists, feel free to point me to that -- I looked around and couldn't find one.)