This package allows Go processes to publish multicast DNS style records onto their local network segment. For more information about mDNS, and it's closely related cousin, Zeroconf, please visit http://www.multicastdns.org/.
This package can be installed using:
go get github.com/ugjka/mdns
Publishing mDNS records is simple
package main
import (
"log"
"os"
"os/signal"
"syscall"
"github.com/ugjka/mdns"
)
func main(){
//ipv4 ipv6
zone, err := mdns.New(true, false)
if err != nil {
log.Fatal(err)
}
zone.Publish("yourhost.local. 60 IN A 192.168.1.2")
zone.Publish("2.1.168.192.in-addr.arpa. 60 IN PTR yourhost.local.")
defer zone.Shutdown()
sig := make(chan os.Signal, 1)
signal.Notify(sig, syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP)
<-sig
log.Println("Shutting down.")
}
Do not mix mDNS stacks, e.g. if you have Avahi daemon running don't use this then