appdir

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 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 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