loader

package
v0.0.0-...-ee86543 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package loader contains Go source loading utilities.

Index

Constants

This section is empty.

Variables

View Source
var ErrExpectedOnlyOnePackage = errors.New("expected only one package")

ErrExpectedOnlyOnePackage reports that loader found several packages, but expected only one.

Functions

func Load

func Load(path string) ([]*packages.Package, error)

Load loads packages from their path.

func LoadComments

func LoadComments(decl ast.Decl) (comments *ast.CommentGroup)

LoadComments gets comments from given declaration.

func LoadOne

func LoadOne(path string) (macro.Context, error)

LoadOne loads exactly one package or returns error if any.

func LoadPackage

func LoadPackage(dir, pattern string, environ []string) ([]*packages.Package, error)

LoadPackage loads packages from pattern using given workdir and environment.

func LoadReader

func LoadReader(r io.Reader, name string) (macro.Context, error)

LoadReader loads source from io.Reader.

func LoadWalk

func LoadWalk(path string, cb func(l Loaded, ctx macro.Context) error) error

LoadWalk loads packages and walks every package file.

Types

type Loaded

type Loaded struct {
	Packages LoadedPackages
	Module   *packages.Module
}

Loaded contains loaded module information.

type LoadedPackages

type LoadedPackages map[string]string

LoadedPackages is a container of loaded packages.

func (LoadedPackages) Add

func (l LoadedPackages) Add(pkg *packages.Package)

Add marks package as loaded.

func (LoadedPackages) Has

func (l LoadedPackages) Has(path string) bool

Has denotes that package already has been loaded.

Jump to

Keyboard shortcuts

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