We'll start by writing the function that will download the data, as follows:
func download() io.Reader { client, err := ftp.Dial("aftp.cmdl.noaa.gov:21") dieIfErr(err) dieIfErr(client.Login("anonymous", "anonymous")) reader, err := client.Retr("products/trends/co2/co2_mm_mlo.txt") dieIfErr(err) return reader}
The NOAA data sits on a publicly accessible FTP server: ftp://aftp.cmdl.noaa.gov/products/trends/co2/co2_mm_mlo.txt. If you visit the URI via a web browser, you would see the data immediately. To access the data programmatically is a little tricky, as this is not a typical HTTP URL.
To handle FTP connections, we will be using the github.com/jlaffaye/ftp package. The package can be installed using the ...