goanalysis

package
v28.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package goanalysis provides a toolset for statically analysing Go applications

Index

Constants

This section is empty.

Variables

View Source
var ErrMultipleMainPackagesFound = errors.New("multiple main packages found")

ErrMultipleMainPackagesFound is returned when multiple main packages found while expecting only one.

Functions

func DiscoverMain

func DiscoverMain(path string) (pkgPaths []string, err error)

DiscoverMain finds main Go packages under path.

func DiscoverOneMain

func DiscoverOneMain(path string) (pkgPath string, err error)

DiscoverOneMain tries to find only one main Go package under path.

func FindBlankImports

func FindBlankImports(node *ast.File) []string

FindBlankImports find all blank imports ('_') into a file.

func FormatImports

func FormatImports(f *ast.File) map[string]string

FormatImports translate f.Imports into a map where name -> package. Name is the alias if declared, or the last element of the package path.

func FuncVarExists

func FuncVarExists(f *ast.File, goImport, methodSignature string) bool

FuncVarExists finds a genesis variable goImport into the go file.

func ReplaceCode added in v28.2.0

func ReplaceCode(pkgPath, oldFunctionName, newFunction string) (err error)

ReplaceCode replace a function implementation into a package path. The method will find the method signature and re-write the method implementation based in the new function.

func UpdateInitImports

func UpdateInitImports(file *ast.File, writer io.Writer, importsToAdd, importsToRemove []string) error

UpdateInitImports helper function to remove and add underscore (init) imports to an *ast.File.

Types

This section is empty.

Jump to

Keyboard shortcuts

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