types

package
v2.3.3 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2020 License: Unlicense Imports: 7 Imported by: 0

Documentation

Overview

Package types contains logic for parsing type definitions from ast packages and filtering those types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dependency

type Dependency struct {
	Type    *ast.TypeSpec
	PkgName string
	PkgPath string
}

A Dependency is a struct containing a package and a dependent type spec.

type Dir

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

A Dir is a type that represents a directory containing Go packages.

func (Dir) Dependencies

func (d Dir) Dependencies(typ *ast.InterfaceType) []Dependency

Dependencies returns all interface types that typ depends on for method parameters or results.

func (Dir) Dir

func (d Dir) Dir() string

Dir returns the directory path that d represents.

func (Dir) ExportedTypes

func (d Dir) ExportedTypes() []*ast.TypeSpec

ExportedTypes returns all *ast.TypeSpecs found by d. Interface types with anonymous interface types will be flattened, for ease of mocking by other logic.

func (Dir) Filter

func (d Dir) Filter(matchers ...*regexp.Regexp) Dir

Filter filters d's types, removing all types that don't match any of the passed in matchers.

func (Dir) Len

func (d Dir) Len() int

Len returns the number of types that will be returned by d.ExportedTypes().

func (Dir) Package

func (d Dir) Package() string

Package returns the name of d's importable package.

type Dirs

type Dirs []Dir

Dirs is a slice of Dir values, to provide sugar for running some methods against multiple Dir values.

func Load

func Load(goDirs ...GoDir) Dirs

Load loads a Dirs value for goDirs.

func (Dirs) Filter

func (d Dirs) Filter(patterns ...string) (dirs Dirs)

Filter calls Dir.Filter for each Dir in d.

type GoDir

type GoDir interface {
	Path() (path string)
	Package() (pkg *packages.Package)
	Import(path string) (pkg *packages.Package, err error)
}

A GoDir is a type that represents a directory of Go files.

Jump to

Keyboard shortcuts

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