utils

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindFile

func FindFile(pkgs map[string]*Pkg, file string) (string, error)

findFile finds the location of the named file in GOROOT, GOPATH etc.

func FindPkgs

func FindPkgs(profiles []*cover.Profile) (map[string]*Pkg, error)

func GetModulePath

func GetModulePath() (string, error)

func Percent

func Percent(covered, total int64) float64

Types

type Directory

type Directory struct {
	Path     string
	Profiles []*cover.Profile
}

func GetProfilesTree

func GetProfilesTree(profiles []*cover.Profile) []Directory

type FuncExtent

type FuncExtent struct {
	Name      string
	StartLine int
	StartCol  int
	EndLine   int
	EndCol    int
}

FuncExtent describes a function's extent in the source by file and position.

func FindFuncs

func FindFuncs(name string) ([]*FuncExtent, error)

FindFuncs parses the file and returns a slice of FuncExtent descriptors.

func (*FuncExtent) Coverage

func (f *FuncExtent) Coverage(profile *cover.Profile) (num, den int64)

Coverage returns the fraction of the statements in the function that were covered, as a numerator and denominator.

type FuncVisitor

type FuncVisitor struct {
	FSet    *token.FileSet
	Name    string // Name of file.
	AstFile *ast.File
	Funcs   []*FuncExtent
}

FuncVisitor implements the visitor that builds the function position list for a file.

func (*FuncVisitor) Visit

func (v *FuncVisitor) Visit(node ast.Node) ast.Visitor

Visit implements the ast.Visitor interface.

type Pkg

type Pkg struct {
	ImportPath string
	Dir        string
	Error      *struct {
		Err string
	}
}

Pkg describes a single package, compatible with the JSON output from 'go list'; see 'go help list'.

Jump to

Keyboard shortcuts

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