{"id":13492152,"url":"https://github.com/rogpeppe/gohack","last_synced_at":"2025-04-04T07:05:49.879Z","repository":{"id":48402381,"uuid":"143596797","full_name":"rogpeppe/gohack","owner":"rogpeppe","description":"Make temporary edits to your Go module dependencies","archived":false,"fork":false,"pushed_at":"2021-07-27T23:26:14.000Z","size":84,"stargazers_count":899,"open_issues_count":27,"forks_count":20,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-28T06:05:43.061Z","etag":null,"topics":["go","golang","modules","vgo"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rogpeppe.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":"2018-08-05T08:42:00.000Z","updated_at":"2025-03-04T10:13:56.000Z","dependencies_parsed_at":"2022-09-26T17:41:16.846Z","dependency_job_id":null,"html_url":"https://github.com/rogpeppe/gohack","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogpeppe%2Fgohack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogpeppe%2Fgohack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogpeppe%2Fgohack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogpeppe%2Fgohack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rogpeppe","download_url":"https://codeload.github.com/rogpeppe/gohack/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247135142,"owners_count":20889420,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["go","golang","modules","vgo"],"created_at":"2024-07-31T19:01:03.546Z","updated_at":"2025-04-04T07:05:49.852Z","avatar_url":"https://github.com/rogpeppe.png","language":"Go","funding_links":[],"categories":["Misc","Go","Repositories"],"sub_categories":[],"readme":"# Gohack: mutable checkouts of Go module dependencies\n\nThe new Go module system is awesome. It ensures repeatable, deterministic\nbuilds of Go code. External module code is cached locally in a read-only\ndirectory, which is great for reproducibility. But if you're used to the\nglobal mutable namespace that is `$GOPATH`, there's an obvious question:\nwhat if I'm hacking on my program and I *want* to change one of those\nexternal modules?\n\nYou might want to put a sneaky `log.Printf` statement to find out how\nsome internal data structure works, or perhaps try out a bug fix to see\nif it solves your latest problem. But since all those external modules\nare in read-only directories, it's hard to change them. And you really\ndon't want to change them anyway, because that will break the integrity\nchecking that the Go tool does when building.\n\nLuckily the modules system provides a way around this: you can add a\n`replace` statement to the `go.mod` file which substitutes the contents\nof a directory holding a module for the readonly cached copy. You can of\ncourse do this manually, but gohack aims to make this process pain-free.\n\n## Install gohack with\n\n\tgo get github.com/rogpeppe/gohack\n\nor use [`gobin`](https://github.com/myitcv/gobin):\n\n\tgobin github.com/rogpeppe/gohack\n\n## For quick edits to a module (without version control information)\nIf the module to edit is `example.com/foo/bar`, run:\n\n\tgohack get example.com/foo/bar\n\nThis will make a _copy_ of the module into `$HOME/gohack/example.com/foo/bar` and\nadd replace directives to the local `go.mod` file:\n\n\treplace example.com/foo/bar =\u003e /home/rog/gohack/example.com/foo/bar\n\n__Note__: This copy will __not__ include version control system information so\nit is best for quick edits that aren't intended to land back into version control.\n\n## To edit the module with full version control\nRun:\n\n\tgohack get -vcs example.com/foo/bar\n\nThis will _clone_ the module's repository to\n`$HOME/gohack/example.com/foo/bar`, check out the correct version of the\nsource code there and add the replace directive into the local `go.mod` file.\n\n## Undoing replacements\n\nOnce you are done hacking and wish to revert to the immutable version, you\ncan remove the replace statement with:\n\n\tgohack undo example.com/foo/bar\n\nor you can remove all gohack replace statements with:\n\n\tgohack undo\n\nNote that undoing a replace does *not* remove the external module's\ndirectory - that stays around so your changes are not lost. For example,\nyou might wish to turn that bug fix into an upstream PR.\n\nIf you run gohack on a module that already has a directory, gohack will\ntry to check out the current version without recreating the repository,\nbut only if the directory is clean - it won't overwrite your changes\nuntil you've committed or undone them.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frogpeppe%2Fgohack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frogpeppe%2Fgohack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frogpeppe%2Fgohack/lists"}