file

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package file provides helpers to locate files based on their import path.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Finder

type Finder struct {
	// contains filtered or unexported fields
}

Finder locates source code files.

func New

func New(options ...Option) *Finder

New returns a new Finder which can be used to locate files from import paths.

It logs locating details on the given logger, if set, at debug level.

func (*Finder) Find

func (finder *Finder) Find(importPath string) (string, error)

Find returns the absolute path of a file from the given import path.

Import path can be either: - a relative path: `./rel/path/to/file.go` - an absolute path: `/abs/path/to/file.go` - an FQDN-based path: `fqdn/path/to/file.go`

FQDN-based paths are resolved based on the GOROOT and GOPATH environment variables, then relative to the `go.mod` file set on the Finder, if any.

type Option

type Option func(finder *Finder)

Option sets an option when constructing a Finder with New.

func WithLogger

func WithLogger(logger *slog.Logger) Option

WithLogger returns an Option which sets the given logger on a Finder.

func WithModFile

func WithModFile(modFile string) Option

WithModFile returns an Option which sets a locally available `go.mod` file to use to resolve file locations on a Finder.

Jump to

Keyboard shortcuts

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