gomod

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package gomod parses go.mod files into a typed, line-annotated structure. It is the single go.mod parser shared by the scope, resolve, mcp, and extract packages, wrapping golang.org/x/mod/modfile.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Exclude

type Exclude struct {
	Path    string
	Version string
	Line    int
}

Exclude is a single exclude directive entry.

type File

type File struct {
	Module    string
	Go        string // e.g. "1.22.3"
	Toolchain string // e.g. "go1.26.4", or ""
	Requires  []Require
	Replaces  []Replace
	Excludes  []Exclude
	Retracts  []Retract
}

File is the parsed content of a go.mod.

func Parse

func Parse(name string, data []byte) (*File, error)

Parse parses go.mod content. name is used only in error messages.

type Replace

type Replace struct {
	OldPath    string
	OldVersion string
	NewPath    string
	NewVersion string
	Line       int
}

Replace is a single replace directive entry. NewVersion is "" for a filesystem-path replacement (e.g. => ../fork).

type Require

type Require struct {
	Path     string
	Version  string
	Indirect bool
	Line     int // 1-indexed line in go.mod
}

Require is a single require directive entry.

type Retract

type Retract struct {
	Low       string
	High      string
	Rationale string
	Line      int
}

Retract is a single retract directive entry. Low == High for a single version; both are set for a range.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL