eqgo

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilesEquivalent

func FilesEquivalent(a *ast.File, fsetA *token.FileSet, b *ast.File, fsetB *token.FileSet, f Formatter) (bool, string)

FilesEquivalent reports whether the Go source files represented by a and b are equivalent. Files are equivalent if their sets of declarations/imports are invariant under reordering, adding/removing spacing/indentation, and adding/removing comments.

This equivalence operator is a relaxation of strict equality which can be useful for verifying whether two differently formatted copies of a codebase are interchangeable from a functional perspective. For example, if you have two code generators which arrange their outputs differently, FilesEquivalent can verify whether, given the same input, the output of one could be swapped with the output of another with no change in behavior to external callers.

Returns: (

A boolean indicating whether the files are equivalent
A message describing the differences found

)

func PackagesEquivalent

func PackagesEquivalent(a *ast.Package, fsetA *token.FileSet, b *ast.Package, fsetB *token.FileSet, f Formatter) (bool, string)

PackagesEquivalent reports whether the Go packages represented by a and b are equivalent. Packages are equivalent if their sets of declarations are invariant under reordering, adding/removing spacing/indentation, and adding/removing comments.

This equivalence operator is a relaxation of strict equality which can be useful for verifying whether two differently formatted copies of a codebase are interchangeable from a functional perspective. For example, if you have two code generators which arrange their outputs differently, PackagesEquivalent can verify whether, given the same input, the output of one could be swapped with the output of another with no change in behavior to external callers.

Returns: (

A boolean indicating whether the packages are equivalent
A message describing any differences found

)

Types

type DefaultFormatter added in v0.3.0

type DefaultFormatter struct {
	LeftFSet, RightFSet *token.FileSet
}

func (DefaultFormatter) Format added in v0.3.0

func (f DefaultFormatter) Format(eq bool, n *node) string

type Formatter added in v0.3.0

type Formatter interface {
	Format(eq bool, n *node) string
}

Jump to

Keyboard shortcuts

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