We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Web Addresses

In the real world, we use physical addresses to help us find where a friend lives, where a business is located, or where a party is being thrown (well, I don't because I'm not invited to parties, but I digress).

In computing, web clients find other computers over the internet using Internet Protocol (IP) addresses. Each device connected to the internet has a unique IP address.

Domain Names and IP Addresses

When we browse the internet, we type in a human readable domain name. That domain is converted into an IP address. The IP address tells our computer where the server is located on the internet.

Click to play video

Assignment

Cloudflare is a tech company that provides a cool HTTP server that we can use to look up the IP address of any domain.

I've provided a getIPAddress function that makes a request to Cloudflare. The function takes a domain name as input and returns the IP address associated with that domain.

The function currently prints a string representation of the entire response we receive from Cloudflare.

    • If there is no IP address, return an empty string and an error.

I've provided a DNSResponse struct in dns.go you might find useful.

If you encounter the error dial tcp 1.1.1.1:443: i/o timeout, Switch to Google's DNS service instead.
Change the url variable in getIPAddress function to utilize "https://dns.google/resolve?name=%s&type=A".