packages

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2025 License: UNKNOWN not legal advice Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PackageKindOther  = iota
	PackageKindRemote = iota
	PackageKindFS
)

Variables

View Source
var (
	ErrResolverPackageNotFound = errors.New("package not found")
	ErrResolverPackageSkip     = errors.New("package has been skip")
)
View Source
var ErrAdjacentSlash = errors.New("** may only be adjacent to '/'")
View Source
var FilterStdlibs = FilterPathMiddleware("stdlibs", isStdPath)

Functions

func CacheAll

func CacheAll(_ *Package) bool

func NormalizeFilepathToPath

func NormalizeFilepathToPath(path string) string

NormalizeFilepathToPath normalize path an unix like path

Types

type BaseLoader

type BaseLoader struct {
	Resolver
}

func NewLoader

func NewLoader(res ...Resolver) *BaseLoader

func (BaseLoader) Load

func (l BaseLoader) Load(paths ...string) ([]Package, error)

func (BaseLoader) Name

func (l BaseLoader) Name() string

func (BaseLoader) Resolve

func (l BaseLoader) Resolve(path string) (*Package, error)

type ChainedResolver

type ChainedResolver []Resolver

func (ChainedResolver) Name

func (cr ChainedResolver) Name() string

func (ChainedResolver) Resolve

func (cr ChainedResolver) Resolve(fset *token.FileSet, path string) (*Package, error)

type FilterPathHandler

type FilterPathHandler func(path string) bool

FilterPathHandler defines the function signature for filter handlers.

type Glob

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

Glob patterns can have the following syntax:

  • `*` to match one or more characters in a path segment
  • `**` to match any number of path segments, including none

Expanding on this:

  • '/' matches one or more literal slashes.
  • any other character matches itself literally.

func Parse

func Parse(pattern string) (*Glob, error)

Parse builds a Glob for the given pattern, returning an error if the pattern is invalid.

func (*Glob) Match

func (g *Glob) Match(input string) bool

Match reports whether the input string matches the glob pattern.

func (*Glob) StarFreeBase

func (g *Glob) StarFreeBase() string

func (*Glob) String

func (g *Glob) String() string

type GlobLoader

type GlobLoader struct {
	Root     string
	Resolver Resolver
}

func NewGlobLoader

func NewGlobLoader(rootpath string, res ...Resolver) *GlobLoader

func (GlobLoader) Load

func (l GlobLoader) Load(gpaths ...string) ([]Package, error)

func (GlobLoader) MatchPaths

func (l GlobLoader) MatchPaths(globs ...string) ([]string, error)

func (GlobLoader) Name

func (l GlobLoader) Name() string

func (GlobLoader) Resolve

func (l GlobLoader) Resolve(path string) (*Package, error)

type Loader

type Loader interface {
	// Load resolves package package paths and all their dependencies in the correct order.
	Load(paths ...string) ([]Package, error)

	// Resolve processes a single package path and returns the corresponding Package.
	Resolve(path string) (*Package, error)

	// Name of the loader
	Name() string
}

type LocalResolver

type LocalResolver struct {
	Path string
	Dir  string
}

func NewLocalResolver

func NewLocalResolver(path, dir string) *LocalResolver

func (LocalResolver) IsValid

func (r LocalResolver) IsValid() bool

func (*LocalResolver) Name

func (r *LocalResolver) Name() string

func (LocalResolver) Resolve

func (r LocalResolver) Resolve(fset *token.FileSet, path string) (*Package, error)

type MiddlewareHandler

type MiddlewareHandler func(fset *token.FileSet, path string, next Resolver) (*Package, error)

func CacheMiddleware

func CacheMiddleware(shouldCache ShouldCacheFunc) MiddlewareHandler

CacheMiddleware creates a caching middleware handler.

func FilterPathMiddleware

func FilterPathMiddleware(name string, filter FilterPathHandler) MiddlewareHandler

func LogMiddleware

func LogMiddleware(logger *slog.Logger) MiddlewareHandler

LogMiddleware creates a logging middleware handler.

func PackageCheckerMiddleware

func PackageCheckerMiddleware(logger *slog.Logger) MiddlewareHandler

PackageCheckerMiddleware creates a middleware handler for post-processing syntax.

type MockResolver

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

func NewMockResolver

func NewMockResolver(pkgs ...*gnovm.MemPackage) *MockResolver

func (*MockResolver) Name

func (m *MockResolver) Name() string

func (*MockResolver) Resolve

func (m *MockResolver) Resolve(fset *token.FileSet, path string) (*Package, error)

func (*MockResolver) ResolveCalls

func (m *MockResolver) ResolveCalls(fset *token.FileSet, path string) int

type NoopResolver

type NoopResolver struct{}

func (NoopResolver) Name

func (NoopResolver) Name() string

func (NoopResolver) Resolve

func (NoopResolver) Resolve(fset *token.FileSet, path string) (*Package, error)

type Package

type Package struct {
	gnovm.MemPackage
	Kind     PackageKind
	Location string
}

func ReadPackageFromDir

func ReadPackageFromDir(fset *token.FileSet, path, dir string) (*Package, error)

type PackageKind

type PackageKind int

type Resolver

type Resolver interface {
	Name() string
	Resolve(fset *token.FileSet, path string) (*Package, error)
}

func ChainResolvers

func ChainResolvers(rs ...Resolver) Resolver

func MiddlewareResolver

func MiddlewareResolver(r Resolver, handlers ...MiddlewareHandler) Resolver

func NewRemoteResolver

func NewRemoteResolver(name string, cl *client.RPCClient) Resolver

func NewRootResolver

func NewRootResolver(path string) Resolver

type ShouldCacheFunc

type ShouldCacheFunc func(pkg *Package) bool

Jump to

Keyboard shortcuts

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