func PublishMDNS(host string, port int) { info := fmt.Sprintf("go-pubsub(%s)", host) service, _ := mdns.NewMDNSService(host, ServiceTag, "", "", port, nil, []string{info}) // Create and run the mDNS server, don't shudown mdns.NewServer(&mdns.Config{Zone: service}) }
func publish(port int, tag string) (*mdns.Server, error) { // Setup our service export host, _ := os.Hostname() // Concatenating host with port allows to discover several instances on the same machine host = fmt.Sprintf("%s.%d", host, port) info := []string{"My awesome service"} service, err := mdns.NewMDNSService(host, tag, "", "", port, nil, info) if err != nil { return nil, err } fmt.Printf("just created service %v\n", service) // Create the mDNS server, defer shutdown server, err := mdns.NewServer(&mdns.Config{Zone: service}) return server, err }