Skip to content

Instantly share code, notes, and snippets.

@aknuds1
Created November 19, 2019 15:47
Show Gist options
  • Save aknuds1/671eb41b272168d01f3966c0d0822d3b to your computer and use it in GitHub Desktop.
Save aknuds1/671eb41b272168d01f3966c0d0822d3b to your computer and use it in GitHub Desktop.
Go program for testing DNS lookup
package main
import (
"net"
"os"
"fmt"
)
func main() {
hostname := os.Args[1]
addrs, err := net.LookupHost(hostname)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to lookup %q: %s\n", hostname, err)
os.Exit(1)
}
fmt.Printf("DNS lookup of %q succeeded: %v\n", hostname, addrs)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment