env

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 4 Imported by: 0 modules, 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 env describes the machine environment the tool runs in.

Index

Constants

View Source
const AppName = "dustpan"

AppName is the only place the product name lives.

Variables

View Source
var Version = "dev"

Version is set via -ldflags "-X .../internal/env.Version=...". Use VersionString to read it.

Functions

func VersionString

func VersionString() string

VersionString returns the build's version: the -ldflags value if one was set, otherwise the module version Go records for `go install ...@vX.Y.Z`, otherwise "dev".

Types

type Env

type Env struct {
	Home      string
	StateDir  string
	ConfigDir string
	TmpDirs   []string
	JobDir    string
	UID       int
	Now       func() time.Time
}

Env holds the locations and clock the rest of the program depends on.

func FromOS

func FromOS() Env

FromOS builds an Env from the process environment.

func (Env) Canon

func (Env) Canon(path string) string

Canon returns the cleaned absolute path with symlinks resolved on its longest existing ancestor; the non-existing remainder is appended unchanged. It never fails: if nothing resolves it returns the cleaned path.

func (Env) CanonParent

func (e Env) CanonParent(path string) string

CanonParent canonicalizes the parent directory of path and appends the final component unchanged, so the item itself is never dereferenced: a symlink stays a symlink rather than becoming its target.

func (Env) EnsureStateDir

func (e Env) EnsureStateDir() error

EnsureStateDir creates the state directory with mode 0700.

Jump to

Keyboard shortcuts

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