refactor: lint with golangci-lint
1 file changed, 9 insertions(+), 3 deletions(-)
changed files
M internal/website/filemap.go → internal/website/filemap.go
@@ -24,19 +24,21 @@ func hashFile(filename string) (string, error) { f, err := os.Open(filename) if err != nil { - return "", err + return "", errors.Wrapf(err, "could not open file %s for hashing", filename) } defer f.Close() hash := fnv.New64a() if _, err := io.Copy(hash, f); err != nil { - return "", err + return "", errors.Wrapf(err, "could not hash file %s", filename) } + return fmt.Sprintf(`W/"%x"`, hash.Sum(nil)), nil } func registerFile(urlpath string, filepath string) error { if files[urlpath] != (File{}) { log.Info("registerFile called with duplicate file", "url_path", urlpath) + return nil } hash, err := hashFile(filepath)@@ -47,6 +49,7 @@ files[urlpath] = File{ filename: filepath, etag: hash, } + return nil }@@ -62,13 +65,16 @@ } urlPath, _ := strings.CutSuffix(relPath, "index.html") if !f.IsDir() { log.Debug("registering file", "urlpath", "/"+urlPath) + return registerFile("/"+urlPath, filePath) } + return nil }) if err != nil { - return err + return errors.Wrap(err, "could not walk directory") } + return nil }