modload

package
v0.13.10 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FlagDepModGop = 1 << iota // depends module github.com/goplus/gop
	FlagDepModX               // depends module github.com/qiniu/x
)

Variables

View Source
var (
	ErrNoModDecl   = errors.New("no module declaration in a .mod file")
	ErrNoModRoot   = errors.New("go.mod file not found in current directory or any parent directory")
	ErrSaveDefault = errors.New("attemp to save default project")
)
View Source
var Default = Module{
	File: &gomodfile.File{
		Module: &gomodfile.Module{},
		Go:     &gomodfile.Go{Version: defaultGoVer},
	},
	Opt: &modfile.File{
		Gop: &modfile.Gop{Version: defaultGopVer},
	},
}

Default represents the default gop.mod object.

Functions

This section is empty.

Types

type Module

type Module struct {
	*gomodfile.File
	Opt *modfile.File
}

func Create

func Create(dir string, modPath, goVer, gopVer string) (p Module, err error)

Create creates a new module in `dir`. You should call `Save` manually to save this module.

func Load

func Load(dir string) (p Module, err error)

Load loads a module from specified directory.

func LoadFrom added in v0.11.9

func LoadFrom(gomod, gopmod string) (p Module, err error)

LoadFrom loads a module from specified go.mod file and an optional gop.mod file.

func LoadFromEx added in v0.12.2

func LoadFromEx(gomod, gopmod string, readFile func(string) ([]byte, error)) (p Module, err error)

LoadFromEx loads a module from specified go.mod file and an optional gop.mod file. It can specify a customized `readFile` to read file content.

func (Module) AddRequire added in v0.13.0

func (p Module) AddRequire(path, vers string, hasProj bool) error

func (Module) DepMods

func (p Module) DepMods() map[string]module.Version

DepMods returns all depended modules. If a depended module path is replace to be a local path, it will be canonical to an absolute path.

func (Module) HasModfile added in v0.12.1

func (p Module) HasModfile() bool

HasModfile returns if this module exists or not.

func (Module) HasProject added in v0.12.0

func (p Module) HasProject() bool

func (Module) Modfile

func (p Module) Modfile() string

Modfile returns absolute path of the module file.

func (Module) Path

func (p Module) Path() string

Path returns the module path.

func (Module) Projects added in v0.12.0

func (p Module) Projects() []*modfile.Project

func (Module) Root

func (p Module) Root() string

Root returns absolute root path of this module.

func (Module) Save

func (p Module) Save() (err error)

Save saves all changes of this module.

func (Module) SaveWithGopMod added in v0.13.1

func (p Module) SaveWithGopMod(gop *env.Gop, flags int) (err error)

SaveWithGopMod adds `require github.com/goplus/gop` and saves all changes of this module.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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