cl

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2021 License: Apache-2.0 Imports: 22 Imported by: 2

Documentation

Overview

Package cl compiles Go+ syntax trees (ast).

Index

Constants

View Source
const (
	DbgFlagLoad = 1 << iota
	DbgFlagLookup
	DbgFlagAll = DbgFlagLoad | DbgFlagLookup
)

Variables

This section is empty.

Functions

func FindGoModFile added in v0.9.0

func FindGoModFile(dir string) (file string, err error)

func GetModulePath added in v0.9.0

func GetModulePath(file string) (pkgPath string, err error)

func NewPackage added in v0.7.0

func NewPackage(pkgPath string, pkg *ast.Package, conf *Config) (p *gox.Package, err error)

NewPackage creates a Go+ package instance.

func SetDebug added in v1.0.0

func SetDebug(flags int)

func SetDisableRecover added in v1.0.0

func SetDisableRecover(disableRecover bool)

Types

type Config added in v0.9.0

type Config struct {
	// Context specifies the context for the load operation.
	// If the context is cancelled, the loader may stop early
	// and return an ErrCancelled error.
	// If Context is nil, the load cannot be cancelled.
	Context context.Context

	// Logf is the logger for the config.
	// If the user provides a logger, debug logging is enabled.
	// If the GOPACKAGESDEBUG environment variable is set to true,
	// but the logger is nil, default to log.Printf.
	Logf func(format string, args ...interface{})

	// Dir is the directory in which to run the build system's query tool
	// that provides information about the packages.
	// If Dir is empty, the tool is run in the current directory.
	Dir string

	// WorkingDir is the directory in which to run gop compiler.
	// TargetDir is the directory in which to generate Go files.
	// If WorkingDir or TargetDir is empty, it is same as Dir.
	WorkingDir, TargetDir string

	// ModPath specifies module path.
	ModPath string

	// ModRootDir specifies root dir of this module.
	// If ModRootDir is empty, will lookup go.mod in all ancestor directories of Dir.
	// If you specify ModPath, you should specify ModRootDir at the same time.
	ModRootDir string

	// CacheFile specifies where cache data to write.
	CacheFile string

	// Env is the environment to use when invoking the build system's query tool.
	// If Env is nil, the current environment is used.
	// As in os/exec's Cmd, only the last value in the slice for
	// each environment key is used. To specify the setting of only
	// a few variables, append to the current environment, as in:
	//
	//	opt.Env = append(os.Environ(), "GOOS=plan9", "GOARCH=386")
	//
	Env []string

	// BuildFlags is a list of command-line flags to be passed through to
	// the build system's query tool.
	BuildFlags []string

	// Fset provides source position information for syntax trees and types.
	// If Fset is nil, Load will use a new fileset, but preserve Fset's value.
	Fset *token.FileSet

	// GenGoPkg is called to convert a Go+ package into Go.
	GenGoPkg func(pkgDir string, base *Config) error

	// PkgsLoader is the Go+ packages loader (will be set if it is nil).
	PkgsLoader *PkgsLoader

	// CacheLoadPkgs = true means to cache all loaded packages.
	CacheLoadPkgs bool

	// PersistLoadPkgs = true means to cache all loaded packages to disk.
	PersistLoadPkgs bool

	// NoFileLine = true means not to generate file line comments.
	NoFileLine bool

	// RelativePath = true means to generate file line comments with relative file path.
	RelativePath bool
}

Config of loading Go+ packages.

func (*Config) Ensure added in v0.9.2

func (conf *Config) Ensure() *Config

type Errors added in v0.9.2

type Errors struct {
	Errs []error
}

func (*Errors) Error added in v0.9.2

func (p *Errors) Error() string

type PkgsLoader added in v0.9.2

type PkgsLoader struct {
	LoadPkgs   gox.LoadPkgsFunc
	BaseConfig *Config
	// contains filtered or unexported fields
}

func (*PkgsLoader) GenGoPkgs added in v0.9.2

func (p *PkgsLoader) GenGoPkgs(cfg *packages.Config, notFounds []string) (err error)

func (*PkgsLoader) Load added in v0.9.2

func (p *PkgsLoader) Load(cfg *packages.Config, patterns ...string) ([]*packages.Package, error)

func (*PkgsLoader) Save added in v1.0.0

func (p *PkgsLoader) Save() error

Directories

Path Synopsis
internal
spx

Jump to

Keyboard shortcuts

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