#go-mod #parser

gomod-parser2

Simple go.mod parser

3 releases

0.4.2 Sep 24, 2025
0.4.1 Jul 17, 2025
0.4.0 Jun 23, 2025

#2582 in Encoding

Download history 7/week @ 2025-10-22 15/week @ 2025-12-10 5/week @ 2025-12-17 33/week @ 2025-12-24 17/week @ 2025-12-31 95/week @ 2026-01-21 124/week @ 2026-01-28 44/week @ 2026-02-04

263 downloads per month

Apache-2.0

21KB
439 lines

This is a temporary fork! Use the official https://docs.rs/gomod-parser/latest/gomod_parser/ instead.

gomod-parser

Build Status Coverage Status Crate MSRV

A simple go.mod file parser based on winnow.

Example

use gomod_parser::{GoMod, Module, ModuleDependency};
use std::str::FromStr;

let input = r#"
module github.com/example

go 1.21

require golang.org/x/net v0.20.0
"#;

let go_mod = GoMod::from_str(input).unwrap();

assert_eq!(go_mod.module, "github.com/example".to_string());
assert_eq!(go_mod.go, Some("1.21".to_string()));
assert_eq!(
    go_mod.require,
    vec![ModuleDependency {
        module: Module {
            module_path: "golang.org/x/net".to_string(),
            version: "v0.20.0".to_string()
        },
        indirect: false
    }]
);

Dependencies

~1MB
~25K SLoC