gopmod

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: 12 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SpxProject = &Project{
		Ext:      ".spx",
		Class:    "Game",
		PkgPaths: []string{"github.com/goplus/spx", "math"},
		Works:    []*modfile.Class{{Ext: ".spx", Class: "Sprite"}},
	}
	GshProject = &Project{
		Ext:      ".gsh",
		Class:    "App",
		PkgPaths: []string{"github.com/qiniu/x/gsh", "math"},
	}
	TestProject = &Project{
		Ext:      "_test.gox",
		Class:    "App",
		PkgPaths: []string{"github.com/goplus/gop/test", "testing"},
		Works:    []*modfile.Class{{Ext: "_test.gox", Class: "Case"}},
	}
)
View Source
var (
	ErrNotFound        = mod.ErrNotFound
	ErrNotClassFileMod = errors.New("not a classfile module")
)
View Source
var Default = New(modload.Default)

Default represents the default gop.mod object.

View Source
var (
	ErrInvalidPkgPath = errors.New("invalid package path")
)

Functions

func IsNotFound added in v0.13.1

func IsNotFound(err error) bool

IsNotFound returns a boolean indicating whether the error is known to report that a module or package does not exist. It is satisfied by ErrNotFound.

Types

type Class

type Class = modfile.Class

type MissingError added in v0.9.11

type MissingError struct {
	Path string
}

func (*MissingError) Error added in v0.9.11

func (e *MissingError) Error() string

type Module

type Module struct {
	modload.Module
	// contains filtered or unexported fields
}

func Load

func Load(dir string) (*Module, error)

Load loads a module from a local directory.

func LoadFrom added in v0.11.9

func LoadFrom(gomod, gopmod string) (*Module, error)

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

func LoadMod

func LoadMod(mod module.Version) (p *Module, err error)

LoadMod loads a module from a versioned module path. If we only want to load a Go modfile, pass env parameter as nil.

func New

func New(mod modload.Module) *Module

New creates a module from a modload.Module instance.

func (*Module) ClassKind added in v0.11.1

func (p *Module) ClassKind(fname string) (isProj, ok bool)

ClassKind checks a fname is a known classfile or not. If it is, then it checks the fname is a project file or not.

func (*Module) DepMods added in v0.13.1

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) ImportClasses added in v0.11.1

func (p *Module) ImportClasses(importClass ...func(c *Project)) (err error)

ImportClasses imports all classfiles found in this module (from go.mod/gop.mod).

func (*Module) IsClass

func (p *Module) IsClass(ext string) (ok bool)

IsClass checks ext is a known classfile or not.

func (*Module) IsPkgtStandard added in v0.12.2

func (p *Module) IsPkgtStandard(pkgPath string) bool

IsPkgtStandard checks if a pkgPath is Go standard package or not.

func (*Module) Lookup

func (p *Module) Lookup(pkgPath string) (pkg *Package, err error)

func (*Module) LookupClass

func (p *Module) LookupClass(ext string) (c *Project, ok bool)

LookupClass lookups a classfile by ext.

func (*Module) LookupDepMod

func (p *Module) LookupDepMod(modPath string) (modVer module.Version, ok bool)

LookupDepMod lookups a depended module. If modVer.Path is replace to be a local path, it will be canonical to an absolute path.

func (*Module) PkgId added in v0.13.2

func (p *Module) PkgId(pkgPath string) (string, error)

PkgId returns an unique package id of specified package. PkgId of a Go standard package is its package path. ie. PkgId("fmt") == "fmt"

func (*Module) PkgType

func (p *Module) PkgType(pkgPath string) PkgType

PkgType returns the package type of specified package.

type Package

type Package struct {
	Type    PkgType
	Dir     string
	ModDir  string
	ModPath string
	Real    module.Version // only when Type == PkgtExtern
}

type PkgType

type PkgType int

PkgType specifies a package type.

const (
	PkgtStandard PkgType = iota // a standard Go/Go+ package
	PkgtModule                  // a package in this module (in standard form)
	PkgtLocal                   // a package in this module (in relative path form)
	PkgtExtern                  // an extarnal package
	PkgtInvalid  = -1           // an invalid package
)

type Project added in v0.10.0

type Project = modfile.Project

Jump to

Keyboard shortcuts

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