Skip to content

proposal: io/fs.Hash and Hasher #43076

Closed
Closed
@earthboundkid

Description

@earthboundkid

Background:

  • When serving an embed.FS as an http.FileSystem, it would be nice to have etag support.
  • Many file stores (e.g. S3) provide a way to get the MD5 hash of file.

Proposal:

Add a func to io/fs to support getting the hash of file.

Perhaps this?

func Hash(fs FS, h hash.Hash, path string) ([]byte, error)

type Hasher interface {
   Hash(h hash.Hash, path string) ([]byte, error)
}

If there's a dependency import issue, maybe put it into package hash.

Ref. #41191 (comment)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions