We have a package `github.com/bitly/nsq/util/lookupd` that has a number of exported functions to do this type of stuff.  You can see it used in `nsqadmin` et al. 

You could probably replace a whole bunch of code wholesale by leveraging that package (plus, it has functions to do the same when only `nsqd` are provided).

P.S. I probably should have mentioned this before you started but it didn't occur to me at the time, my bad :frown: