appdir

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

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

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 returns the first candidate directory that matches Markers. DiscoverHome 返回第一个匹配 Markers 的候选目录。

Example / 示例:

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

Types

type CandidateSource added in v0.1.3

type CandidateSource uint8

CandidateSource selects where 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 DiscoverHome. Options 配置 DiscoverHome。

Jump to

Keyboard shortcuts

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