Skip to content

Commit

Permalink
Add Delete Fn in Cache pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
pivilartisant committed Aug 8, 2024
1 parent 3103e69 commit 3399f98
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pkg/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,19 @@ func (c *Cache) Save(fileName string, content []byte) error {

return nil
}

// Delete removes a file from the cache.
func (c *Cache) Delete(fileName string) error {

Check failure on line 82 in pkg/cache/cache.go

View workflow job for this annotation

GitHub Actions / lint

unnecessary leading newline (whitespace)

Check failure on line 83 in pkg/cache/cache.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gofumpt`-ed (gofumpt)
fullPath, err := fullPath(fileName, c.ConfigDir)
if err != nil {
return fmt.Errorf("while reading cached file %s: %w", fileName, err)
}

err = os.Remove(fullPath)
if err != nil {
return fmt.Errorf("while deleting from cache: %v", err)

Check failure on line 91 in pkg/cache/cache.go

View workflow job for this annotation

GitHub Actions / lint

non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)
}

return nil
}

0 comments on commit 3399f98

Please sign in to comment.