module

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package module provides helper functions to handle GX modules.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Module

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

Module is the GX module.

func Current

func Current() (*Module, error)

Current returns the module of the current working directory.

func New

func New(osPath string) (*Module, error)

New returns a new module given a directory. If no directory is given (i.e. empty string), then the current working directory is used. If no go.mod can be find, returns a nil module with a nil error.

func (*Module) Belongs

func (mod *Module) Belongs(importPath string) bool

Belongs returns true if a package, given its path, belongs to the module.

func (*Module) Deps added in v0.5.0

func (mod *Module) Deps() []*module.Version

Deps returns a list of all the direct dependencies.

func (*Module) FS

func (mod *Module) FS() fs.ReadDirFS

FS returns the filesystem for the current module.

func (*Module) File added in v0.3.0

func (mod *Module) File() *modfile.File

File returns the module go.mod file.

func (*Module) GXPathFromOS added in v0.5.0

func (mod *Module) GXPathFromOS(osPath string) (string, error)

GXPathFromOS returns the GX package from an OS path. Returns an empty string if the path does not belong to the package.

func (*Module) ImportToOSPath

func (mod *Module) ImportToOSPath(importPath string) (string, error)

ImportToOSPath converts an import path to a path on the operating system.

func (*Module) Name

func (mod *Module) Name() string

Name of the module as specified in the go.mod file.

func (*Module) OSPath

func (mod *Module) OSPath(path string) string

OSPath converts a path within the module to a path on the operating system.

func (*Module) Root added in v0.5.0

func (mod *Module) Root() string

Root returns the parent directory of go.mod.

func (*Module) Split

func (mod *Module) Split(importPath string) (packagePath, packageName string, err error)

Split a full package into a module path, a package path, and a package name.

func (*Module) VersionOf added in v0.5.0

func (mod *Module) VersionOf(path string) string

VersionOf returns the version of a given module path or an empty string if not found.

Jump to

Keyboard shortcuts

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