FuncFind

module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 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 a specific type
  • Lazy evaluation: Uses Go 1.23+ iterators for memory-efficient traversal
  • Standard library compatible: Works with any Go package, including the standard library
  • Exact matching: Finds functions with exactly one return value of the specified type

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())
    }
}

How It Works

FuncFind uses Go's golang.org/x/tools/go/packages to load package information and go/types for type analysis. The process:

Limitations

  • Only finds functions with exactly one return value.
    • It's possible to extend to arbitrary number of return values later.
  • 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