pathutil

package
v0.0.0-...-95e8c34 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2022 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package pathutil implements utilities for handing file paths.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddExtPrefix

func AddExtPrefix(path string, extPrefix string) string

AddExtPrefix adds a prefix to the path's file extension and returns a new path.

For example: AddExtPrefix("foo/bar/baz.js", ".bak") = "foo/bar/baz.bak.js"

func Copy

func Copy(from, to string) error

Copy copies the file from a source path to a destination path, overwriting the destination if it already exists.

func FileLines

func FileLines(path string) ([]string, error)

FileLines reads in a file and returns it as an array of lines.

func SubstituteHomeAndXdg

func SubstituteHomeAndXdg(path string) string

SubstituteHomeDir takes a path that might be prefixed with `~`, or may contain XDG variables, and substitutes them with the appropriate path.

func SubstituteHomeDir

func SubstituteHomeDir(path string) string

SubstituteHomeDir takes a path that might be prefixed with `~`, and returns the path with the `~` replaced by the user's home directory.

When running inside a Flatpak, we use executil.Command to fetch $HOME from the host system.

Types

This section is empty.

Jump to

Keyboard shortcuts

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