{"id":37991741,"url":"https://github.com/defrankland/hasherator","last_synced_at":"2026-01-16T18:44:03.115Z","repository":{"id":57513502,"uuid":"86106311","full_name":"defrankland/hasherator","owner":"defrankland","description":"Go/golang cache-busting package. Tags asset file names with a hash and copies to a separate directory. ","archived":false,"fork":false,"pushed_at":"2017-12-01T14:10:20.000Z","size":34,"stargazers_count":5,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-19T19:46:49.620Z","etag":null,"topics":["cache-busting","go"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/defrankland.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-24T20:04:05.000Z","updated_at":"2023-02-20T01:45:49.000Z","dependencies_parsed_at":"2022-08-31T23:00:56.110Z","dependency_job_id":null,"html_url":"https://github.com/defrankland/hasherator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/defrankland/hasherator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defrankland%2Fhasherator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defrankland%2Fhasherator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defrankland%2Fhasherator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defrankland%2Fhasherator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/defrankland","download_url":"https://codeload.github.com/defrankland/hasherator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defrankland%2Fhasherator/sbom","scorecard":{"id":332520,"data":{"date":"2025-08-11","repo":{"name":"github.com/defrankland/hasherator","commit":"53a1d2e6df4a889fd50628a222db3c4f730cdd26"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/19 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-18T03:56:35.081Z","repository_id":57513502,"created_at":"2025-08-18T03:56:35.081Z","updated_at":"2025-08-18T03:56:35.081Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28481180,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cache-busting","go"],"created_at":"2026-01-16T18:44:03.041Z","updated_at":"2026-01-16T18:44:03.108Z","avatar_url":"https://github.com/defrankland.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hasherator\n\nGolang package that will perform a md5 hash on each file within a directory (and its subdirectories) and append the result to the name of that file. \n\nThis allows your Go backend to deliver CSS, JS, etc. files to the browser without having to clear the file caching\nevery time there is a change. \n\nThe intended usage is to run it at your application's startup and have it create a working directory, which contains\nthe same files as the source directory but with the hash string inserted in the name. The reason for doing this is so \nthat your project repo can contain files with the non-hashed name, and the working directory can be added to .gitignore. \n\nPlease note that currently the working directory must be different from the source directory. \n\n## API\n \n Check out the hasherator_test.go for further example of usage. \n \n There is just one exported function: \n \n ```go\n func (a *AssetsDir) Run(sourcePath, workingPath string, noHashDirs []string) error\n ```\n \n  - sourcePath - directory containing the files you want to hash\n  - workingPath - directory where you want the hashed files to go (will be created if it does not exist)\n  - noHashDirs - names of any directories that you do not want to hash\n \n A map is also created on the AssetsDir object that contains the original (source) file name as the key and the hashed \n file name as the value. \n \n \n ## Usage \n \n ### Hashing Files\n Intended operation is to perform this on application launch:\n \n ```go\nassets := AssetsDir{}\nerr := assets.Run(\"./mySource/\", \"./MyDestination/\", []string{\"doNotHashThisDirectory\", \"ThisOneEither\"})\n ```\n \nThe `assets` instance can be passed to the HTTP controllers if the `assets.Map` is needed for reference, or if files need to be re-hashed at runtime.\n \n ### Applying in Go Templates \n If using Go templates for page rendering, the following can be used to reference the hashed file names: \n \n ```html\n \u003clink rel=\"stylesheet\" href='../assets/css/{{index .AssetsMap \"bootstrap.min.css\"}}'\u003e\n ```\n \n This will look up the key in assets map and render to the associated value. The final product for example should result in \n  bootstrap.min.css pointing to:\n \n ```go\n  \u003clink rel=\"stylesheet\" href='../assets/css/bootstrap.min-ec3bb52a00e176a7181d454dffaea219.css'\u003e\n  ```\n\n### Update Asset Files At Runtime\nAnother thing that might be useful -- File modifications can be loaded at runtime (without shutting down and restarting the application). Say you have an `originalAssets` instance you created at startup. Then, you could create a goroutine containing:\n\n```go\nnewAssets := AssetsDir{}\nerr := assets.Run(\"./mySource/\", \"./NewDestination/\", []string{\"doNotHashThisDirectory\", \"ThisOneEither\"})\nif err != nil {\n //whatever\n}\n\nfor i := 0; i \u003c len(newAssets.Map); i++ {\n if originalAssets.Map[i] != newAssets.Map[i] {\n  //delete the originalAssets directory and rename the newAssets directory\n  break\n }\n}\n```\n\nOr better yet, trigger the goroutine with [fsnotify](https://github.com/fsnotify/fsnotify).\n\n```go \nwatcher    *fsnotify.Watcher\n\nwatcher, err = fsnotify.NewWatcher()\nif err != nil {\n //log error\n}\ndefer watcher.Close()\n\nwatcher.Add(\"webapp/templates/\")\nwatcher.Add(\"webapp/assets/css/\")\nwatcher.Add(\"webapp/assets/js/\")\n\nfor {\n select {\n case event := \u003c-watcher.Events:\n  if (event.Op\u0026fsnotify.Create == fsnotify.Create ||\n   event.Op\u0026fsnotify.Write == fsnotify.Write) \u0026\u0026\n   !strings.Contains(event.Name, \"___\") {\n\n   assets = \u0026hasherator.AssetsDir{}\n\n   err = os.RemoveAll(\"/webappRuntime2/\")\n   if err != nil {\n    //log error\n   }\n   \n   err := assets.Run(\"webapp/\",\n    \"webappRuntime2/\", \n    []string{\"templates\", \"fonts\"})\n   if err != nil {\n    //log error\n   }\n\n   err = os.RemoveAll(\"webappRuntime/\")\n   if err != nil {\n    //log error\n   }\n   err = os.Rename(\"webappRuntime2/\", \"webappRuntime/\")\n   if err != nil {\n    //log error\n   }\n\n   basecontroller.SetAssetsMap(assets.Map)\n   //log success message!\n  }\n case err := \u003c-watcher.Errors:\n  //log error\n }\n time.Sleep(500 * time.Millisecond)\n}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefrankland%2Fhasherator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdefrankland%2Fhasherator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefrankland%2Fhasherator/lists"}