Documentation ¶
Index ¶
- Constants
- func RelativePathToTarget(path string) (rel string, recurse bool, err error)
- func SetExcludeDir(pattern string) func(*Checker)
- func SetExcludeFile(pattern string) func(*Checker)
- func SetVCS(vcs VCS) func(*Checker)
- func SetVLog(w io.Writer) func(*Checker)
- type Change
- type Checker
- type DeclChange
- type DeclChecker
- type Git
- type StrVCS
- type VCS
Constants ¶
const ( None = "no change" NonBreaking = "non-breaking change" Breaking = "breaking change" )
The different declaration messages the package can generate.
Variables ¶
This section is empty.
Functions ¶
func RelativePathToTarget ¶
RelativePathToTarget returns the relative path to the given path, wether it's an import path or direct path and also returns if the path had recursion requested (/...).
func SetExcludeDir ¶
SetExcludeDir excludes checking of a directory based on regexp pattern. Usually only help when running recursively.
func SetExcludeFile ¶
SetExcludeFile excludes checking of files based on regexp pattern
Types ¶
type Change ¶
type Change struct { Pkg string // Pkg is the name of the package the change occurred in ID string // ID is an identifier to match a declaration between versions Msg string // Msg describes the change Change string // Change describes whether it was unknown, no change, non-breaking or breaking change Pos string // Pos is the ASTs position prefixed with a version Before ast.Decl // Before is the previous declaration After ast.Decl // After is the new declaration }
Change is the ast declaration containing the before and after
type Checker ¶
type Checker struct {
// contains filtered or unexported fields
}
Checker is used to check for changes between two versions of a package.
type DeclChange ¶
type DeclChange struct { // Change is the type of change, see None, NonBreaking and Breaking. Change string // Msg describes what changed, such as "members added". Msg string // Pos is the position of the change. Pos token.Pos }
DeclChange represents a single change between 2 revision.
type DeclChecker ¶
type DeclChecker struct {
// contains filtered or unexported fields
}
DeclChecker takes a list of changes and verifies which, if any, change breaks the API.
func NewDeclChecker ¶
func NewDeclChecker(bi, ai *types.Info) *DeclChecker
NewDeclChecker creates a DeclChecker.
func (DeclChecker) Check ¶
func (c DeclChecker) Check(before, after ast.Decl) (DeclChange, error)
Check compares two declarations and returns the DeclChange associated with that change. For example, comments aren't compared, names of arguments aren't compared etc.
type Git ¶
type Git struct {
// contains filtered or unexported fields
}
Git implements vcs and uses exec.Command to access repository
func (*Git) DefaultRevision ¶
DefaultRevision returns the default revisions if none specified
type StrVCS ¶
type StrVCS struct {
// contains filtered or unexported fields
}
StrVCS provides a in memory vcs used for testing, but does not support subdirectories.
func (StrVCS) DefaultRevision ¶
DefaultRevision implements VCS.DefaultRevision
func (StrVCS) OpenFile ¶
func (v StrVCS) OpenFile(revision, path string) (io.ReadCloser, error)
OpenFile implements VCS.OpenFile
type VCS ¶
type VCS interface { // ReadDir returns a list of files in a directory at revision ReadDir(revision, path string) ([]os.FileInfo, error) // OpenFile returns a reader for a given absolute path at a revision OpenFile(revision, path string) (io.ReadCloser, error) // DefaultRevision returns the default revisions if none specified DefaultRevision() (before string, after string) }
VCS defines a version control system the vcs should be able to handle calls to ReadFile concurrently A special case for the revision of "." (without quotes) is used to check local filesystem