FuncFind

module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2025 License: MIT

README

FuncFind

CI

FuncFind is a Go library for discovering functions by their return types using static analysis. It leverages Go's type system and the go/types package to efficiently find functions that return specific types across Go packages.

Features

  • Type-based function discovery: Find all functions that return specific type(s)
  • Lazy evaluation: Uses Go 1.23+ iterators for memory-efficient traversal
  • Flexible matching: Finds functions matching an exact sequence of return types

Installation

go get github.com/MrUsefull/FuncFind

Usage

Basic Example
package main

import (
    "fmt"
    "slices"
    
    "github.com/MrUsefull/FuncFind/pkg/funcfind"
)

func main() {
    // Find all functions in the fmt package that return an error
    functions, err := funcfind.Returning("fmt", "error")
    if err != nil {
        panic(err)
    }
    
    for fn := range functions {
        fmt.Println(fn.Name())
    }
    
    // Find all functions in the fmt package that return (int, error)
    functions, err = funcfind.Returning("fmt", "int", "error")
    if err != nil {
        panic(err)
    }
    
    for fn := range functions {
        fmt.Printf("%s returns (int, error)\n", fn.Name())
    }
}

Limitations

  • Functions must match the exact number and order of return types specified
  • Type matching is done by string comparison of type representations
  • Requires the target package to be accessible and compilable
  • Does not find unexported functions in external packages

Development

Running Tests
go test ./...
Running Linting
golangci-lint run
Building
go build ./...

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

License

MIT

Directories

Path Synopsis
pkg
funcfind
Package funcfind provides static analysis tools for discovering Go functions by their return types.
Package funcfind provides static analysis tools for discovering Go functions by their return types.

Jump to

Keyboard shortcuts

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