{"id":17911564,"url":"https://github.com/sanposhiho/gomockhandler","last_synced_at":"2026-04-23T12:01:17.881Z","repository":{"id":45192159,"uuid":"344893853","full_name":"sanposhiho/gomockhandler","owner":"sanposhiho","description":"Mr. gomockhandler is the clever and more agile manager of golang/mock (uber/mock) 👔","archived":false,"fork":false,"pushed_at":"2024-10-17T00:27:56.000Z","size":4816,"stargazers_count":117,"open_issues_count":6,"forks_count":9,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-17T17:57:58.975Z","etag":null,"topics":["cli","go","golang","mock","mockgen","mocks"],"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/sanposhiho.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"sanposhiho","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2021-03-05T18:04:58.000Z","updated_at":"2025-08-22T09:36:19.000Z","dependencies_parsed_at":"2023-11-24T05:23:22.108Z","dependency_job_id":"3281a92e-d3cc-4ed7-bbfd-635d8050d778","html_url":"https://github.com/sanposhiho/gomockhandler","commit_stats":null,"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"purl":"pkg:github/sanposhiho/gomockhandler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanposhiho%2Fgomockhandler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanposhiho%2Fgomockhandler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanposhiho%2Fgomockhandler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanposhiho%2Fgomockhandler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sanposhiho","download_url":"https://codeload.github.com/sanposhiho/gomockhandler/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanposhiho%2Fgomockhandler/sbom","scorecard":{"id":799828,"data":{"date":"2025-08-11","repo":{"name":"github.com/sanposhiho/gomockhandler","commit":"8e67a0b8f4843c2d2286aeb0526971ffa3c39f9f"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4,"checks":[{"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":"Code-Review","score":3,"reason":"Found 10/30 approved changesets -- score normalized to 3","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":"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":"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":"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":"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":"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":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"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 22 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"}},{"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"}}]},"last_synced_at":"2025-08-23T10:07:34.091Z","repository_id":45192159,"created_at":"2025-08-23T10:07:34.091Z","updated_at":"2025-08-23T10:07:34.091Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32179387,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-23T11:42:27.955Z","status":"ssl_error","status_checked_at":"2026-04-23T11:42:18.877Z","response_time":53,"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":["cli","go","golang","mock","mockgen","mocks"],"created_at":"2024-10-28T19:39:18.393Z","updated_at":"2026-04-23T12:01:17.869Z","avatar_url":"https://github.com/sanposhiho.png","language":"Go","funding_links":["https://github.com/sponsors/sanposhiho"],"categories":[],"sub_categories":[],"readme":"# gomockhandler\n\nMr. gomockhandler is the clever and fast manager of mocks generated by [uber-go/mock](https://github.com/uber-go/mock) (or [golang/mock](https://github.com/golang/mock)).\n\n\u003cimg src=\"https://user-images.githubusercontent.com/44139130/131862740-6b4bfba8-be02-43d0-99d1-62efd8318381.JPG\" width=\"400px\"\u003e\n\n`gomockhandler` uses one config file to generate all mocks.\n\nWith `gomockhandler`,\n\n- You can generate mocks **in parallel** :rocket:.\n- You can check if mock is **up-to-date** :sparkles:.\n- You can manage your mocks in **one config file** :books:.\n\n## Background\n\nSome of you may often manage your mocks with `go generate` like below.\n\n```\n//go:generate mockgen -source=$GOFILE -destination=mock_$GOFILE -package=$GOPACKAG\n```\n\nBut, it will take long time to generate a log of mocks with `go generate ./...`, because `go generate` executes `mockgen` **one by one**. \n\nAnd we cannot easily check if mock is up-to-date; people often forget to update mocks when the interface is changed.\n\n`gomockhandler` is created to solve all of these problems.\n\nAnd with this background, it is designed to make it easy to switch from managing mocks with `go generate` to managing mocks with gomockhandler.\n\n## Install\n\nYou have to install `mockgen` first.\n\n```\ngo install go.uber.org/mock/mockgen@latest\n```\n\nNext, install gomockhandler.\n\n```\ngo install github.com/sanposhiho/gomockhandler@latest\n```\n\n## How to use\n\n`gomockhandler` is designed to be **simple** and does only three things.\n\n- generate/edit a config with CLI\n- generate mocks from config\n- check if mocks are up-to-date\n\nThese are the options for using the gomockhandler.\n\n```\n-config string\n  The path to config file.\n  The default value is \"./gomockhandler.json\"\n  \n-target_dir string\n  Only mocks under the specified directory will be targeted for commands `check` and `mockgen`.\n  By default, all files will be targeted.\n\n-ignore string\n  Comma-separated glob patterns to ignore (e.g., 'testdata,*_generated.go,mock_*').\n  Supports glob wildcards: '*' (any characters), '?' (single character).\n  The 'vendor' directory is always ignored.\n\n-f bool\n  If true, it will also generate mocks whose source has not been updated.\n  The default value is false.\n```\n\n\n## Getting started\n\nYou need a config for `gomockhandler`.\n\nHowever, you don't need to generate/edit the config directly, it can be generated/edited from CLI.\n\n### configuring a new mock\n\nYou can configure a new mock to be generated with `gomockhandler` CLI. \n\nIf a gomockhandler config file does not exist, it will be created.\n\ngomockhandler CLI is compatible with `mockgen` command which you can do anything you do with `mockgen`\nSee [golang/mock#running-mockgen](https://github.com/uber-go/mock#running-mockgen) for more information about the two modes and mockgen options.\n\nSource mode:\n```\ngomockhandler -config=/path/to/gomockhandler.json -source=foo.go -destination=./mock/ [other mockgen options]\n```\n\nReflect mode:\n```\ngomockhandler -config=/path/to/gomockhandler.json -destination=./mock/ [other mockgen options] database/sql/driver Conn,Driver\n```\n\n---\n\nFor example, suppose you want to configure the mock generated by the following `mockgen` command to be generated by `gomockhandler`\n\n```\nmockgen -source=foo.go -destination=../mock/\n```\n\nThe following command will add the information of the mock you want to generate to the configuration.\nAs you can see, you just need to think about the option `config`. (The default value is `./gomockhandler.json`)\n\n```\ngomockhandler -config=/path/to/gomockhandler.json -source=foo.go -destination=../mock/\n```\n\n### [TIPS] switch from `go generate` to gomockhandler\n\ngomockhandler is designed to make it easy to switch from managing mocks with `go generate` to managing mocks with gomockhandler.\n\nIf you use `go:generate` to execute mockgen now, you can generate the config file by rewriting `go:generate` comment a little bit.\n\nReplace from `mockgen` to `gomockhandler -config=/path/to/gomockhandler.json` in all `go:generate` comments, and run `go generate ./...` in your project. And then,\n\n```\n- //go:generate mockgen -source=$GOFILE -destination=mock_$GOFILE -package=$GOPACKAG\n+ //go:generate gomockhandler -config=/path/to/gomockhandler.json -source=$GOFILE -destination=mock_$GOFILE -package=$GOPACKAG\n```\n\nAfter generating the config, your `go:generate` comments are no longer needed. You've been released from a slow-mockgen with `go generate`!\n\nLet's delete all `go:generate` comments for mockgen in your project.\n\n### Recommendations\n\n- name the config file `gomockhandler.json`, and place it in a location where the gomockhandler is likely to be run frequently.\n- use **Source Mode**, if there is no great reason to use Reflect mode., which is much faster because the gomockhandler will skip processing if the source file has not been changed.\n\n### delete mocks to be generated from config\n\nYou can remove the mocks to be generated from the config.\n\n```\ngomockhandler -config=/path/to/gomockhandler.json -destination=./mock/user.go deletemock \n```\n\nThis command only delete the mock from the configuration. So please delete the mock file itself manually.\n\n## generate mock\n\nYou can generate all mocks from config.\n\n```\ngomockhandler -config=/path/to/gomockhandler.json mockgen\n```\n\n## check if mock is up-to-date\n\nYou can check if the mock is generated based on the latest interface.\n\nIt is useful for ci.\n\n```\ngomockhandler -config=/path/to/gomockhandler.json check\n```\nIf some mocks are not up to date, you can see the error and `gomockhandler` will exit with exit-code 1\n\n```\n2021/03/10 22:17:12 [WARN] mock is not up to date. source: ./interfaces/user.go, destination: ./interfaces/../mock/user.go\n2021/03/10 22:17:12 mocks is not up-to-date\n```\n\n## edit config manually\n\nYou can edit the config manually.\n\nBut, it is **RECOMMENDED** to use [CLI](https://github.com/sanposhiho/gomockhandler#generateedit-a-config), especially for adding/editing mocks. (This is because CLI will check if mockgen works correctly with that option, and then edit the config.)\n\nThe config json file has the following format.\n\n```\n{\n\t\"mocks\": {\n\t\t\"mock/user.go\": {\n\t\t\t\"checksum\": \"qxZ/pLjLBtib7o+kDLOzOQ==\",\n\t\t\t\"source_checksum\": \"UUyR0gaRX4IbPPAttwOCXw==\",\n\t\t\t\"mode\": \"SOURCE_MODE\",\n\t\t\t\"source_mode_runner\": {\n\t\t\t\t\"source\": \"interfaces/user.go\",\n\t\t\t\t\"destination\": \"mock/user.go\"\n\t\t\t}\n\t\t},\n\t\t\"mock/user2.go\": {\n\t\t\t\"checksum\": \"qxZ/pLjLBtib7o+kDLOzOQ==\",\n\t\t\t\"source_checksum\": \"AAAAAAAAAAAAAAAAAAAAAA==\",\n\t\t\t\"mode\": \"REFLECT_MODE\",\n\t\t\t\"reflect_mode_runner\": {\n\t\t\t\t\"package_name\": \"playground/interfaces\",\n\t\t\t\t\"interfaces\": \"User2\",\n\t\t\t\t\"destination\": \"mock/user2.go\"\n\t\t\t}\n\t\t}\n\t}\n}\n```\n\nAs mentioned above, there are two modes of mockgen, and the format of the config is slightly different depending on which mode you are using.\nIn the `***mode-runner` field, specify the option to be used when running mockgen.\n\nIn the `checksum` field, the checksum of the currently generated mock is stored. With this checksum, the gomockhandler checks if the mock is the same as the mock generated from the latest interface.\n\nIn the `source_checksum` field, the checksum of the currently generated mock's source file is stored. This field is only valid in source mode, and when reflect mode is used, the value will be `AAAAAAAAAAAAAAAAAAAAAA==`.\n\n## contributing\n\nsee [CONTRIBUTING.md](CONTRIBUTING.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsanposhiho%2Fgomockhandler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsanposhiho%2Fgomockhandler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsanposhiho%2Fgomockhandler/lists"}