Created
January 15, 2019 15:36
-
-
Save miguelmota/7bb806fb9e305fa848abb8482eddc543 to your computer and use it in GitHub Desktop.
Golang DNS lookup (ip, mx, txt, etc)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net" | |
) | |
func main() { | |
ips, err := net.LookupIP("google.com") | |
if err != nil { | |
panic(err) | |
} | |
fmt.Println(ips) | |
mx, err := net.LookupMX("google.com") | |
if err != nil { | |
panic(err) | |
} | |
fmt.Println(mx) | |
txt, err := net.LookupTXT("google.com") | |
if err != nil { | |
panic(err) | |
} | |
fmt.Println(txt) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment