added gotch.CleanCache API

This commit is contained in:
sugarme 2022-02-24 16:40:27 +11:00
parent cd7cc90d02
commit 8eab6a5bbd
2 changed files with 12 additions and 0 deletions

View File

@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
- Added `gotch.CleanCache()` API.
## [Nofix]
- ctype `long` caused compiling error in MacOS as noted on [#44]. Not working on linux box.

View File

@ -287,3 +287,14 @@ func copyFile(src, dst string) error {
_, err = io.Copy(destination, source)
return err
}
// CleanCache removes all files cached at `CacheDir`
func CleanCache() error {
err := os.RemoveAll(CacheDir)
if err != nil {
err = fmt.Errorf("CleanCache() failed: %w", err)
return err
}
return nil
}