tool

package
v1.3.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound      = gopmod.ErrNotFound
	ErrIgnoreNotated = errors.New("notated error ignored")
)
View Source
var (
	ErrMultiPackges     = errors.New("multiple packages")
	ErrMultiTestPackges = errors.New("multiple test packages")
)

Functions

func BuildDir

func BuildDir(dir string, conf *Config, build *gocmd.BuildConfig, flags ...GenFlags) (err error)

BuildDir builds a Go+ package directory.

func BuildFiles

func BuildFiles(files []string, conf *Config, build *gocmd.BuildConfig) (err error)

BuildFiles builds specified Go+ files.

func BuildPkgPath

func BuildPkgPath(workDir, pkgPath string, conf *Config, build *gocmd.BuildConfig, flags ...GenFlags) (err error)

BuildPkgPath builds a Go+ package.

func ErrorPos

func ErrorPos(err error) token.Pos

ErrorPos returns where the error occurs.

func FilterNoTestFiles

func FilterNoTestFiles(fi fs.FileInfo) bool

FilterNoTestFiles filters to skip all testing files.

func GenGo

func GenGo(dir string, conf *Config, genTestPkg bool) (string, bool, error)

GenGo generates gop_autogen.go for a Go+ package directory.

func GenGoEx

func GenGoEx(dir string, conf *Config, genTestPkg bool, flags GenFlags) (string, bool, error)

GenGoEx generates gop_autogen.go for a Go+ package directory.

func GenGoFiles

func GenGoFiles(autogen string, files []string, conf *Config) (outFiles []string, err error)

GenGoFiles generates gop_autogen.go for specified Go+ files.

func GenGoPkgPath

func GenGoPkgPath(workDir, pkgPath string, conf *Config, allowExtern bool) (localDir string, recursively bool, err error)

GenGoPkgPath generates gop_autogen.go for a Go+ package.

func GenGoPkgPathEx

func GenGoPkgPathEx(workDir, pkgPath string, conf *Config, allowExtern bool, flags GenFlags) (localDir string, recursively bool, err error)

GenGoPkgPathEx generates gop_autogen.go for a Go+ package.

func GetFileClassType

func GetFileClassType(mod *gopmod.Module, file *ast.File, filename string) (classType string, isTest bool)

GetFileClassType get gop module file classType.

func IgnoreNotated

func IgnoreNotated(err error) bool

IgnoreNotated returns if cause err is ErrIgnoreNotated or not.

func InstallDir

func InstallDir(dir string, conf *Config, install *gocmd.InstallConfig, flags ...GenFlags) (err error)

InstallDir installs a Go+ package directory.

func InstallFiles

func InstallFiles(files []string, conf *Config, install *gocmd.InstallConfig) (err error)

InstallFiles installs specified Go+ files.

func InstallPkgPath

func InstallPkgPath(workDir, pkgPath string, conf *Config, install *gocmd.InstallConfig, flags ...GenFlags) (err error)

InstallPkgPath installs a Go+ package.

func LoadDir

func LoadDir(dir string, conf *Config, genTestPkg bool, promptGenGo ...bool) (out, test *gogen.Package, err error)

LoadDir loads Go+ packages from a specified directory.

func LoadFiles

func LoadFiles(dir string, files []string, conf *Config) (out *gogen.Package, err error)

LoadFiles loads a Go+ package from specified files.

func LoadMod

func LoadMod(dir string) (mod *gopmod.Module, err error)

LoadMod loads a Go+ module from a specified directory.

func NotFound

func NotFound(err error) bool

NotFound returns if cause err is ErrNotFound or not

func Outline

func Outline(dir string, conf *Config) (out outline.Package, err error)

func OutlinePkgPath

func OutlinePkgPath(workDir, pkgPath string, conf *Config, allowExtern bool) (out outline.Package, err error)

func RunDir

func RunDir(dir string, args []string, conf *Config, run *gocmd.RunConfig, flags ...GenFlags) (err error)

RunDir runs an application from a Go+ package directory.

func RunFiles

func RunFiles(autogen string, files []string, args []string, conf *Config, run *gocmd.RunConfig) (err error)

RunFiles runs an application from specified Go+ files.

func RunPkgPath

func RunPkgPath(pkgPath string, args []string, chDir bool, conf *Config, run *gocmd.RunConfig, flags ...GenFlags) (err error)

RunPkgPath runs an application from a Go+ package.

func TestDir

func TestDir(dir string, conf *Config, test *gocmd.TestConfig, flags ...GenFlags) (err error)

TestDir tests a Go+ package directory.

func TestFiles

func TestFiles(files []string, conf *Config, test *gocmd.TestConfig) (err error)

TestFiles tests specified Go+ files.

func TestPkgPath

func TestPkgPath(workDir, pkgPath string, conf *Config, test *gocmd.TestConfig, flags ...GenFlags) (err error)

TestPkgPath tests a Go+ package.

func Tidy

func Tidy(dir string, gop *env.Gop) (err error)

Types

type ConfFlags

type ConfFlags int

ConfFlags represents configuration flags.

const (
	ConfFlagIgnoreNotatedError ConfFlags = 1 << iota
	ConfFlagDontUpdateGoMod
	ConfFlagNoTestFiles
	ConfFlagNoCacheFile
)

type Config

type Config struct {
	Gop      *env.Gop
	Fset     *token.FileSet
	Mod      *gopmod.Module
	Importer *Importer

	Filter func(fs.FileInfo) bool

	// If not nil, it is used for returning result of checks Go+ dependencies.
	// see https://pkg.go.dev/github.com/goplus/gogen#File.CheckGopDeps
	GopDeps *int

	// CacheFile specifies the file path of the cache.
	CacheFile string

	IgnoreNotatedError bool
	DontUpdateGoMod    bool
}

Config represents a configuration for loading Go+ packages.

func NewDefaultConf

func NewDefaultConf(dir string, flags ConfFlags, tags ...string) (conf *Config, err error)

NewDefaultConf creates a dfault configuration for common cases.

func (*Config) NewGoCmdConf

func (conf *Config) NewGoCmdConf() *gocmd.Config

func (*Config) UpdateCache

func (conf *Config) UpdateCache(verbose ...bool)

UpdateCache updates the cache.

type GenFlags

type GenFlags int
const (
	GenFlagCheckOnly GenFlags = 1 << iota
	GenFlagSingleFile
	GenFlagPrintError
	GenFlagPrompt
)

type Importer

type Importer struct {
	Flags GenFlags // can change this for loading Go+ modules
	// contains filtered or unexported fields
}

Importer represents a Go+ importer.

func NewImporter

func NewImporter(mod *gopmod.Module, gop *env.Gop, fset *token.FileSet) *Importer

NewImporter creates a Go+ Importer.

func (*Importer) Cache

func (p *Importer) Cache() *cache.Impl

Cache returns the cache object.

func (*Importer) CacheFile

func (p *Importer) CacheFile() string

CacheFile returns file path of the cache.

func (*Importer) Import

func (p *Importer) Import(pkgPath string) (pkg *types.Package, err error)

Import imports a Go/Go+ package.

func (*Importer) PkgHash

func (p *Importer) PkgHash(pkgPath string, self bool) string

PkgHash calculates hash value for a package. It is required by cache.New func.

func (*Importer) SetTags

func (p *Importer) SetTags(tags string)

Jump to

Keyboard shortcuts

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