...

Package modcmd

import "cmd/go/internal/modcmd"
Overview
Index

Overview ▾

Package modcmd implements the “go mod” command.

Variables

var CmdMod = &base.Command{
    UsageLine: "go mod",
    Short:     "module maintenance",
    Long: `Go mod provides access to operations on modules.

Note that support for modules is built into all the go commands,
not just 'go mod'. For example, day-to-day adding, removing, upgrading,
and downgrading of dependencies should be done using 'go get'.
See 'go help modules' for an overview of module functionality.
    `,

    Commands: []*base.Command{
        cmdDownload,
        cmdEdit,
        cmdGraph,
        cmdInit,
        cmdTidy,
        cmdVendor,
        cmdVerify,
        cmdWhy,
    },
}

func DownloadModule

func DownloadModule(ctx context.Context, m *ModuleJSON) error

DownloadModule runs 'go mod download' for m.Path@m.Version, leaving the results (including any error) in m itself.

func RunVendor

func RunVendor(ctx context.Context, vendorE bool, vendorO string, args []string)

type ModuleJSON

A ModuleJSON describes the result of go mod download.

type ModuleJSON struct {
    Path     string `json:",omitempty"`
    Version  string `json:",omitempty"`
    Query    string `json:",omitempty"`
    Error    string `json:",omitempty"`
    Info     string `json:",omitempty"`
    GoMod    string `json:",omitempty"`
    Zip      string `json:",omitempty"`
    Dir      string `json:",omitempty"`
    Sum      string `json:",omitempty"`
    GoModSum string `json:",omitempty"`

    Origin *codehost.Origin `json:",omitempty"`
    Reuse  bool             `json:",omitempty"`
}