Compute document hashes compatible with godocs.
External tools can use this library to pre-check whether a document already exists before uploading.
MD5 of the raw file bytes, formatted as 32-character lowercase hex.
go get github.com/drummonds/godocs-hashimport godocshash "github.com/drummonds/godocs-hash"
hash, err := godocshash.HashFile("invoice.pdf")
// Check: GET https://your-godocs/api/document/lookup?hash=<hash>
// 200 → already exists, skip upload
// 404 → upload via POST /api/document/uploadThree functions are provided:
HashFile(path)— hash a file by pathHashReader(r)— hash from anyio.ReaderHashBytes(data)— hash in-memory bytes
md5sum invoice.pdf | cut -d' ' -f1import hashlib
hashlib.md5(open("invoice.pdf", "rb").read()).hexdigest()| Documentation | https://h3-godocs-hash.statichost.page/ |
| Source (Codeberg) | https://codeberg.org/hum3/godocs-hash |
| Mirror (GitHub) | https://github.com/drummonds/godocs-hash |
| Docs repo | https://codeberg.org/hum3/godocs-hash-docs |