appdir

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 5 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package appdir discovers application home directory. 应用程序主目录发现。

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoCandidates = errors.New("appdir: no candidates available")
	ErrNotFound     = errors.New("appdir: cannot discover home directory")
	ErrEnvInvalid   = errors.New("appdir: env home is invalid")
)

Functions

func DiscoverHome

func DiscoverHome(opts Options) (string, error)

DiscoverHome finds the first candidate directory containing marker files. DiscoverHome 查找第一个包含标记文件的候选目录。

Example / 示例:

home, _ := appdir.DiscoverHome(appdir.Options{EnvVar: "APP_HOME", Markers: []string{"configs"}})

Types

type CandidateSource added in v0.1.3

type CandidateSource uint8

CandidateSource controls which locations DiscoverHome searches. CandidateSource 控制 DiscoverHome 搜索哪些候选来源。

const (
	SourceEnvVar CandidateSource = 1 << iota
	SourceExecutable
	SourceWorkingDir
)

type Options

type Options struct {
	EnvVar            string
	Markers           []string
	RequireDirMarkers bool
	Sources           CandidateSource
}

Options configures home directory discovery. Options 配置主目录发现。

Jump to

Keyboard shortcuts

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