Help us shape the future of Go! Take the 2026 Go Developer Survey

scanner

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package scanner discovers environment files under user-chosen roots.

It never walks the whole filesystem: callers pass explicit roots, and well-known dependency/cache directories are pruned.

Index

Constants

This section is empty.

Variables

View Source
var DefaultExcludes = []string{
	".git", "node_modules", "vendor", ".cache", "Library",
	"dist", "build", ".next", ".nuxt", ".turbo", ".venv", "venv",
	"__pycache__", ".terraform", ".gradle", "target", ".idea", ".vscode",
}

DefaultExcludes are directory names that are never descended into.

Functions

func IsEnvFile

func IsEnvFile(name string) bool

IsEnvFile reports whether a file name looks like an environment file: .env, .env.<anything>, env, env.<anything>.

func IsTemplate

func IsTemplate(name string) bool

IsTemplate reports whether the env file is an example/template file.

func ProjectOf

func ProjectOf(path string) string

ProjectOf names the project a file belongs to: the nearest git root above it (up to the home directory), else its parent directory.

Types

type Options

type Options struct {
	Excludes        []string // directory names to prune; nil means DefaultExcludes
	IncludeTemplate bool     // include .env.example & friends
	MaxFileSize     int64    // skip larger files; 0 means 1 MiB
}

Options configures a scan.

type Result

type Result struct {
	Path        string `json:"path"`         // absolute path
	Root        string `json:"root"`         // scan root it was found under
	RelPath     string `json:"rel_path"`     // path relative to Root
	ProjectDir  string `json:"project_dir"`  // git root, else containing dir
	ProjectName string `json:"project_name"` // base name of ProjectDir
	InGitRepo   bool   `json:"in_git_repo"`
	IsTemplate  bool   `json:"is_template"`
	Size        int64  `json:"size"`
}

Result is a discovered environment file.

func Scan

func Scan(roots []string, opt Options) ([]Result, error)

Scan walks each root and returns env files sorted by path.

Jump to

Keyboard shortcuts

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