{"id":32929142,"url":"https://github.com/sify21/gomod-rs","last_synced_at":"2025-11-11T11:07:42.943Z","repository":{"id":241261778,"uuid":"804522044","full_name":"sify21/gomod-rs","owner":"sify21","description":"go.mod file parser with locations","archived":false,"fork":false,"pushed_at":"2024-05-24T02:57:41.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-29T12:23:33.212Z","etag":null,"topics":["gomod","nom","rust-library"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/sify21.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-05-22T18:40:55.000Z","updated_at":"2024-05-24T02:57:44.000Z","dependencies_parsed_at":"2024-05-23T07:32:10.729Z","dependency_job_id":"12ab0d08-636f-4b7a-8b74-09edcd5449ef","html_url":"https://github.com/sify21/gomod-rs","commit_stats":null,"previous_names":["sify21/gomod-rs"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sify21/gomod-rs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sify21%2Fgomod-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sify21%2Fgomod-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sify21%2Fgomod-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sify21%2Fgomod-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sify21","download_url":"https://codeload.github.com/sify21/gomod-rs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sify21%2Fgomod-rs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":283838925,"owners_count":26903264,"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","status":"online","status_checked_at":"2025-11-11T02:00:06.610Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["gomod","nom","rust-library"],"created_at":"2025-11-11T11:07:36.976Z","updated_at":"2025-11-11T11:07:42.935Z","avatar_url":"https://github.com/sify21.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gomod-rs\n\n[![LICENSE](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n[![crates.io Version](https://img.shields.io/crates/v/gomod-rs)](https://crates.io/crates/gomod-rs)\n\nA [go.mod](https://go.dev/ref/mod#go-mod-file) file parser with location information.\n\nImplemented using [nom](https://github.com/rust-bakery/nom) and [nom\\_locate](https://github.com/fflorent/nom_locate).\n\n**No string copy/clone during parsing.**\n\n(except for [interpreted strings](https://go.dev/ref/mod#go-mod-file-lexical), which yield `Identifier::Interpreted(String)` type)\n\n## Example Usage\nHere is an example printing all requirements defined in a go.mod file, along with their locations and related contents.\n```rust\nuse gomod_rs::{parse_gomod, Context, Directive};\n\nlet contents = r#\"module example.com/my/thing\n\ngo 1.12\n\nrequire (\n    example.com/other/thing v1.0.2\n    example.com/new/thing/v2 v2.3.4\n)\n\nexclude example.com/old/thing v1.2.3\nreplace example.com/bad/thing v1.4.5 =\u003e example.com/good/thing v1.4.5\nretract [v1.9.0, v1.9.5]\"#;\nlet gomod = parse_gomod(\u0026contents)?;\ngomod\n    .iter()\n    .filter_map(|i| match i {\n        Context {\n            value: Directive::Require { specs },\n            ..\n        } =\u003e Some(specs),\n        _ =\u003e None,\n    })\n    .for_each(|require_specs| {\n        require_specs.iter().for_each(|spec| {\n            println!(\n                \"Requirement {{name: {}, version: {}}} at line {}, fragment: {}\",\n                spec.value.0,\n                \u0026spec.value.1 as \u0026str,\n                spec.range.0.line,\n                \u0026contents[spec.range.0.offset..spec.range.1.offset]\n            );\n        });\n    });\n```\nAbove will ouput:\n```\nRequirement {name: example.com/other/thing, version: v1.0.2} at line 6, fragment: example.com/other/thing v1.0.2\n\nRequirement {name: example.com/new/thing/v2, version: v2.3.4} at line 7, fragment: example.com/new/thing/v2 v2.3.4\n```\nYou can also `cargo run --example parse -- /path/to/go.mod`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsify21%2Fgomod-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsify21%2Fgomod-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsify21%2Fgomod-rs/lists"}