xgomod

package
v0.22.1 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: Apache-2.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	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/xgo/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 gox.mod object.

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

Functions

func IsNotFound

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 DepMod added in v0.20.0

type DepMod struct {
	Path string // module path
	Real module.Version
}

DepMod represents a depended module, which is used for loading external packages.

type MissingError

type MissingError struct {
	Path string
}

func (*MissingError) Error

func (e *MissingError) Error() string

type Module

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

Module represents a XGo module, which is based on a Go module. It provides some helper methods for loading XGo modules and packages.

func Load

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

Load loads a module from a local directory.

func LoadFrom

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

LoadFrom loads a module from specified go.mod file and an optional gox.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) ClassInfo added in v0.21.2

func (p *Module) ClassInfo(fname string) (autoLambdas map[string]int, isProj, ok bool)

ClassInfo checks a fname is a known classfile or not. If it is, it returns the auto-lambda map, whether it is a project file, and true. See https://github.com/goplus/xgo/issues/2828 to learn about auto lambda.

func (*Module) ClassKind deprecated

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.

Deprecated: use ClassInfo instead.

func (*Module) DepMods

func (p *Module) DepMods() []DepMod

DepMods returns all depended modules, sorted by module path in descending order (longest prefix first). If a depended module path is replaced by a local path, it will be canonicalized to an absolute path.

func (*Module) ImportClasses

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

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

func (*Module) IsClass

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

IsClass checks ext is a known classfile or not.

func (*Module) IsPkgtStandard

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

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/XGo 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

type Project = modfile.Project

Jump to

Keyboard shortcuts

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