Documentation
¶
Index ¶
- func FindExportedFuncsWithoutTests(pkgPath string) ([]string, error)
- func GHRelease(newVer string) error
- func GoReleaser() error
- func InstallGoDeps(deps []string) error
- func InstallVSCodeModules() error
- func ModUpdate(recursive bool, v bool) error
- func Tidy() error
- func UpdateMageDeps(magedir string) error
- type FuncInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindExportedFuncsWithoutTests ¶
FindExportedFuncsWithoutTests finds all exported functions in a given package path that do not have corresponding tests.
Parameters:
pkgPath: A string specifying the package path to search.
Returns:
[]string: A slice of strings containing the names of exported functions that do not have corresponding tests.
error: An error if there was a problem parsing the package or finding the tests.
Example:
funcs, err := FindExportedFuncsWithoutTests("github.com/myorg/mypackage")
if err != nil {
log.Fatalf("failed to find exported functions without tests: %v", err)
}
for _, funcName := range funcs {
fmt.Println(funcName)
}
func GHRelease ¶
GHRelease creates a new release on GitHub with the given new version. It requires that the gh CLI tool is available on the PATH.
Parameters:
newVer: A string specifying the new version, e.g., "v1.0.1"
Returns:
error: An error if the GHRelease function was not successful.
Example:
newVer := "v1.0.1" err := GHRelease(newVer)
if err != nil {
log.Fatalf("failed to create new GH release: %v", err)
}
func GoReleaser ¶
func GoReleaser() error
GoReleaser runs the Goreleaser tool to generate all the supported binaries specified in a .goreleaser configuration file.
Returns:
error: An error if the Goreleaser function was not successful.
Example:
err := GoReleaser()
if err != nil {
log.Fatalf("failed to run GoReleaser: %v", err)
}
func InstallGoDeps ¶
InstallGoDeps installs the specified Go dependencies by running 'go install' for each dependency.
Parameters:
deps: A slice of strings specifying the dependencies to install.
Returns:
error: An error if the InstallGoDeps function was not successful.
Example:
deps := []string{"github.com/stretchr/testify", "github.com/go-chi/chi"} err := InstallGoDeps(deps)
if err != nil {
log.Fatalf("failed to install Go dependencies: %v", err)
}
func InstallVSCodeModules ¶
func InstallVSCodeModules() error
InstallVSCodeModules installs the modules used by the vscode-go extension in Visual Studio Code.
Returns:
error: An error if the InstallVSCodeModules function was not successful.
Example:
err := InstallVSCodeModules()
if err != nil {
log.Fatalf("failed to install VS Code modules: %v", err)
}
func ModUpdate ¶
ModUpdate updates go modules by running 'go get -u' or 'go get -u ./...' if recursive is set to true. The function will run in verbose mode if 'v' is set to true.
Parameters:
recursive: A boolean specifying whether to run the update recursively. v: A boolean specifying whether to run the update in verbose mode.
Returns:
error: An error if the ModUpdate function was not successful.
Example:
recursive := true verbose := true err := ModUpdate(recursive, verbose)
if err != nil {
log.Fatalf("failed to update modules: %v", err)
}
func Tidy ¶
func Tidy() error
Tidy runs 'go mod tidy' to clean up the module dependencies.
Returns:
error: An error if the Tidy function was not successful.
Example:
err := Tidy()
if err != nil {
log.Fatalf("failed to tidy modules: %v", err)
}
func UpdateMageDeps ¶
UpdateMageDeps updates the dependencies in a specified Magefile directory. If no directory is provided, it defaults to the 'magefiles' directory.
Parameters:
magedir: A string specifying the path to the magefiles directory.
Returns:
error: An error if the UpdateMageDeps function was not successful.
Example:
magedir := "custom/mage/dir" err := UpdateMageDeps(magedir)
if err != nil {
log.Fatalf("failed to update Mage dependencies: %v", err)
}
Types ¶
type FuncInfo ¶
type FuncInfo struct {
// FilePath is the file path of the source file containing the function declaration.
FilePath string
// FuncName is the name of the exported function.
FuncName string
}
FuncInfo contains information about an exported function, including the file path and function name.
func FindExportedFunctionsInPackage ¶
FindExportedFunctionsInPackage finds all exported functions in a given Go package by recursively parsing all non-test Go files in the package directory and returning a slice of FuncInfo structs, each containing the file path and the name of an exported function. If no exported functions are found in the package, an error is returned.
Parameters:
pkgPath: A string representing the path to the directory containing the package to search for exported functions.
Returns:
[]FuncInfo: A slice of FuncInfo structs, each containing the file path and the name of an exported function found in the package. error: An error if no exported functions are found.
Example:
packagePath := "/path/to/your/go/package" funcs, err := FindExportedFunctionsInPackage(packagePath)
if err != nil {
log.Fatalf("failed to find exported functions: %v", err)
}
for _, f := range funcs {
log.Printf("Exported function %s found in file %s\n", f.Name, f.FilePath)
}