{"id":13492204,"url":"https://github.com/marwan-at-work/mod","last_synced_at":"2025-05-15T16:05:00.079Z","repository":{"id":34509079,"uuid":"146152814","full_name":"marwan-at-work/mod","owner":"marwan-at-work","description":"Automated Semantic Import Versioning Upgrades","archived":false,"fork":false,"pushed_at":"2025-03-18T16:48:42.000Z","size":56,"stargazers_count":395,"open_issues_count":3,"forks_count":26,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-07T22:04:26.860Z","etag":null,"topics":["go","golang","modules"],"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/marwan-at-work.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-26T05:02:57.000Z","updated_at":"2025-04-07T12:03:30.000Z","dependencies_parsed_at":"2023-01-15T07:31:15.475Z","dependency_job_id":"15adee31-8c56-4d67-8441-8ee18ea84dea","html_url":"https://github.com/marwan-at-work/mod","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marwan-at-work%2Fmod","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marwan-at-work%2Fmod/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marwan-at-work%2Fmod/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marwan-at-work%2Fmod/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marwan-at-work","download_url":"https://codeload.github.com/marwan-at-work/mod/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254374410,"owners_count":22060610,"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"],"created_at":"2024-07-31T19:01:04.001Z","updated_at":"2025-05-15T16:05:00.026Z","avatar_url":"https://github.com/marwan-at-work.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# Mod \n\nCommand line tool to upgrade/downgrade Semantic Import Versioning in Go Modules\n\n### Motivation \n\nThere are two good use cases to do this: \n\n1. If you own a library and you want to introduce a breaking change, then you have to go around all your Go files and sub-packages and update the import paths to include v2, v3, etc. This tool just does it automatically with one command. \n\n2. If you own a library that is already tagged v2 or above but is incompatible with Semantic Import Versioning, then \nthis tool can solve the problem for you with one command as well. Introduce a go.mod file with the correct import path, and just run `mod upgrade` once or `mod -t=X upgrade` (where x is the latest tag major) to update the import paths of your go files to match whatever tag you're at.\n\n### Install\n\n`go install github.com/marwan-at-work/mod/cmd/mod@latest`\n\n### Usage\n\n`mod upgrade` OR `mod downgrade` from any directory that has go.mod file.\n\n\nThe tool will update the major version in the go.mod file and it will \ntraverse all the Go Files and upgrades/downgrades any imports as well. \n\nFor example, if you have the following package: \n\n```\n// go.mod\n\nmodule github.com/me/example\n\nrequire github.com/pkg/errors v0.8.0\n```\n\nthat imports a sub directory in its Go files:\n\n```golang\n// example.go\n\npackage example\n\nimport (\n    \"github.com/me/example/subdir\"\n)\n\n// rest of file...\n```\n\nYou can run `mod upgrade` from the root of that directory and the above two files will be rewritten as such: \n\n```\nmodule github.com/me/example/v2\n\nrequire github.com/pkg/errors\n```\n\n```golang\npackage example\n\nimport (\n    \"github.come/me/example/v2/subdir\"\n)\n\n// rest of file...\n```\n\nYou can of course, downgrade again or upgrade more incrementally. \n\nYou can also run this command inside the example folder \nand notice how the import paths and the module name alike get updated.\n\n#### Upgrading a dependency\n\nSay you are using a dependency like `github.com/x/y/v2` and you want to use the new major version they just released. You don't want to change your own import paths, but you want to change the import paths of a dependency you're using from `v2` to `v3`. \n\nAll you have to do is \n\n```\nmod upgrade --mod-name=github.com/x/y\n```\n\n#### Downgrading a dependency\n\nSay you are using a dependency like `github.com/x/y/v3` and you want to use the previous major version. You don't want to change your own import paths, but you want to change the import paths of a dependency you're using from `v3` to `v2`.\n\nAll you have to do is\n\n```\nmod downgrade --mod-name=github.com/x/y\n```\n\n## Status\n\nWorks as intended. Feel free to report any issues.\n\n### Troubleshooting\n\nIf you are using iTerm2 and see this error: \n\n```\n\u003chtml\u003e\u003chead\u003e\u003c/head\u003e\u003cbody\u003e\u003cp\u003e\u003cem\u003eError:\u003c/em\u003e Your request has found no candidate provider [hs=\"(null)\", id=\"(null)\"]\u003c/p\u003e\u003c/body\u003c/html\u003e\n```\n\nMake sure you close iTerm2 and start again. See https://github.com/marwan-at-work/mod/issues/3 for details. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarwan-at-work%2Fmod","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarwan-at-work%2Fmod","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarwan-at-work%2Fmod/lists"}