1.5 Fetching a URL
For many applications, access to information from the Internet is
as important as access to the local file system. Go provides a
collection of packages, grouped under net, that make it easy to send
and receive information through the Internet, make low-level network
connections, and set up servers, for which Go’s concurrency
features (introduced in Chapter 8) are particularly useful.
To illustrate the minimum necessary to retrieve information over HTTP,
here’s a simple program called fetch that fetches the content of
each specified URL and prints it as uninterpreted text; it’s inspired by the
invaluable utility curl. Obviously one would usually do more with such data, but this shows the basic idea. We will use this program ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access