Skip to content

Go Mod ParserComprehensive Go Module Parser

Parse and analyze go.mod files with ease

Go Mod Parser

Quick Example

go
package main

import (
    "fmt"
    "log"
    
    "github.com/scagogogo/go-mod-parser/pkg"
)

func main() {
    // Parse a go.mod file
    mod, err := pkg.ParseGoModFile("go.mod")
    if err != nil {
        log.Fatalf("Failed to parse go.mod: %v", err)
    }
    
    // Access parsed data
    fmt.Printf("Module: %s\n", mod.Name)
    fmt.Printf("Go Version: %s\n", mod.GoVersion)
    
    // List dependencies
    for _, req := range mod.Requires {
        fmt.Printf("- %s %s\n", req.Path, req.Version)
    }
}

Installation

bash
go get github.com/scagogogo/go-mod-parser

Use Cases

  • Dependency Analysis Tools - Build tools to analyze project dependencies
  • Module Version Management - Create systems for managing module versions
  • CI/CD Pipeline Integration - Check dependencies in continuous integration
  • Build Tools - Integrate into Go project build systems
  • Dependency Visualization - Create visual representations of module relationships
  • Update Recommendation Systems - Build tools that suggest dependency updates

Released under the MIT License.