Skip to content

Instantly share code, notes, and snippets.

@lsowen
Created September 11, 2014 20:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lsowen/4f51a27cc58cf56884b4 to your computer and use it in GitHub Desktop.
Save lsowen/4f51a27cc58cf56884b4 to your computer and use it in GitHub Desktop.
Example DNS-SD query
package main
import (
"fmt"
"os"
"github.com/armon/mdns"
"sync"
)
func channelHandler(wg sync.WaitGroup, ch <-chan mdns.ServiceEntry) {
go func() {
for entry := range ch {
fmt.Println("Entry Found: " , entry)
wg.Done()
}
}()
}
func main() {
entriesCh := make(chan mdns.ServiceEntry)
var wg sync.WaitGroup
wg.Add(1)
channelHandler(wg, entriesCh)
mdns.ResolveService(os.Args[1], entriesCh)
wg.Wait()
close(entriesCh)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment