Skip to content

Instantly share code, notes, and snippets.

@lalyos
Created June 13, 2015 08:23
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lalyos/b8a4d03c028cc24be36e to your computer and use it in GitHub Desktop.
Save lalyos/b8a4d03c028cc24be36e to your computer and use it in GitHub Desktop.
DNS SRV record test in golang
package main
import (
"fmt"
"net"
"os"
)
func main() {
if len(os.Args) < 2 {
fmt.Fprintln(os.Stderr, "Usage: dnstest <SERVICE>")
os.Exit(1)
}
srv := os.Args[1]
fmt.Fprintln(os.Stderr, "service:", srv)
cname, addr, err := net.LookupSRV("", "", srv)
if err != nil {
fmt.Fprintln(os.Stderr, "[ERROR]", err)
}
fmt.Println("cname:", cname)
for _, a := range addr {
fmt.Printf(" %s %d\n", a.Target, a.Port)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment