// Package cache provides cache keys
package key import ( ) // Key provides a cache key. type Key func() (string, error) // String creates a CacheKey for given strings. func ( ...string) Key { return func() (string, error) { return strings.Join(, "\n"), nil } } // FileChecksum creates a CacheKey for given file. func ( string) Key { return func() ( string, error) { var []byte if , = os.ReadFile(); == nil { = fmt.Sprintf("%x", sha1.Sum()) } return } } // FileStats creates a CacheKey for given file. func ( string) Key { return func() ( string, error) { var string if , = filepath.Abs(); == nil { var os.FileInfo if , = os.Stat(); == nil { return String(, strconv.FormatInt(.Size(), 10), .ModTime().String())() } } return } } func ( string) Key { return func() (string, error) { := make([]string, 0) := filepath.Walk(, func( string, fs.FileInfo, error) error { if !.IsDir() { , := String(.Name(), strconv.FormatInt(.Size(), 10), .ModTime().String())() if != nil { return } = append(, ) } return nil }) if != nil { return "", } return strings.Join(, "\n"), nil } }