Documentation
¶
Overview ¶
Package gomod reads and edits the go.mod of a project through the go command.
go mod edit works offline and keeps the file formatted the way go writes it, which is why it is used instead of editing the text.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddTool ¶
AddTool declares a tool. The module is required at the given version unless the project already requires it: a version the project chose is kept.
func DropTool ¶
DropTool removes a tool declaration. The require line stays until go mod tidy finds it unused, which keeps a module the project imports itself.
func SetLocalReplace ¶ added in v0.9.0
func SetLocalReplace(dir string, r LocalReplace) error
SetLocalReplace points a replace directive at another folder.
Types ¶
type File ¶
type File struct {
Module string
Go string // the go directive
Requires map[string]string // module path to version
Replaced []string // module paths with a replace directive
Local []LocalReplace // replace directives that point at a folder
Tools []string // packages declared with tool
}
File is the part of go.mod platformgo cares about.
type LocalReplace ¶ added in v0.9.0
type LocalReplace struct {
Path, Version string
Dir string // as written: relative to the project or absolute
}
LocalReplace is a replace directive with a folder on the right: Path[@Version] => Dir.