func (c *Cache) Load() error {
	csvfile, err := os.Open(c.location)
	defer csvfile.Close()
	if err != nil {
		if os.IsNotExist(err) {
			return nil
		}
		return err
	}
	fileinfo, err := csvfile.Stat()
	if err != nil {
		return err
	}
	if time.Now().Sub(fileinfo.ModTime()) > c.timeout {
		return nil
	}
	r := csv.NewReader(csvfile)
	for {
		record, err := r.Read()
		if err == io.EOF {
			break
		}
		if err != nil {
			return err
		}
		entry := CacheEntry{
			host: record[0],
			ipv4: record[1],
			ipv6: record[2],
		}
		c.entries = append(c.entries, entry)
	}
	return nil
}
Load loads the cache from its location. When there is no file at the
cache location it will do nothing. If the last modification to the file
was made before the cache timeout it will ignore the file content.
package main
import (
	"encoding/csv"
	"io"
	"os"
	"time"
)
const (
	defaultDir     string = "/dyndns-netcup-go"
	defaultIPCache string = "ip.cache"
)
type Cache struct {
	location string
	timeout  time.Duration
	changes  bool
	entries  []CacheEntry
}
type CacheEntry struct {
	host string
	ipv4 string
	ipv6 string
}
func NewCache(location string, timeout time.Duration) (*Cache, error) {
	if location == "" {
		var err error
		location, err = os.UserCacheDir()
		if err != nil {
			return nil, err
		}
		location += defaultDir
		if _, err := os.Stat(location); os.IsNotExist(err) {
			os.MkdirAll(location, 0700)
		}
		location += "/" + defaultIPCache
	}
	return &Cache{location, timeout, false, nil}, nil
}