pathutil

package
v0.0.212 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package pathutil provides shared path manipulation utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Expand

func Expand(path string) (string, error)

Expand resolves shell-style tilde expansions in a path:

  • "~" → current user's home directory
  • "~/subpath" → current user's home directory + subpath
  • "~username" → named user's home directory
  • "~username/subpath" → named user's home directory + subpath

All other paths are returned unchanged. "." and ".." components are not resolved here; callers should pass the result through filepath.Abs or filepath.Clean as needed.

Note: "~username" lookup uses the OS user database. An error is returned if the named user does not exist.

func MustExpand

func MustExpand(path string) string

MustExpand is like Expand but returns the original path unchanged on error instead of surfacing the error. Useful in contexts where errors are non-fatal (e.g. serving default directories).

Types

This section is empty.

Jump to

Keyboard shortcuts

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