func loadKey(name string) ([]byte, error) {
	if _, err := os.Stat(name); os.IsNotExist(err) {
		if err := generateNewKey(name); err != nil {
			return nil, err
		}
	}
	f, err := os.Open(name)
	if err != nil {
		return nil, err
	}
	key := make([]byte, securecookie.KeyLen)
	n, err := f.Read(key)
	if err != nil {
		return nil, err
	}
	if n != securecookie.KeyLen {
		return nil, fmt.Errorf("key lenght is %d, it should be %d", n, securecookie.KeyLen)
	}
	return key, nil
}
loadKey loads the key saved in file named name. A new key is generated and saved
in a file named name if the file does not exist.
package main
import (
	"fmt"
	"html"
	"log"
	"net/http"
	"os"
	"strings"
	"github.com/chmike/securecookie"
)
func generateNewKey(name string) error {
	key, err := securecookie.GenerateRandomKey()
	if err != nil {
		return err
	}
	os.Remove(name)
	f, err := os.OpenFile(name, os.O_CREATE|os.O_WRONLY, 0600)
	if err != nil {
		return err
	}
	if _, err = f.Write(key); err != nil {
		return err
	}
	f.Close()
	return nil
}