github.com/simpleiot/simpleiot@v0.18.3/cmd/mdns-test/main.go (about)

     1  // mdns test
     2  package main
     3  
     4  import (
     5  	"fmt"
     6  
     7  	"github.com/simpleiot/mdns"
     8  )
     9  
    10  func main() {
    11  	// Make a channel for results and start listening
    12  	entriesCh := make(chan *mdns.ServiceEntry, 4)
    13  	go func() {
    14  		for entry := range entriesCh {
    15  			fmt.Printf("Got new entry: %v\n", entry)
    16  		}
    17  	}()
    18  
    19  	// Start the lookup
    20  	_ = mdns.Lookup("_http._tcp", entriesCh)
    21  	close(entriesCh)
    22  }