utils

package
v3.53.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package utils provides some file- and filepath-helper functions.

TODO: `utils` is too vague. Find a better name for this package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChmodExecutable

func ChmodExecutable(filename string) error

ChmodExecutable sets the executable mode/flag on a file, if not already.

func ExpandHome

func ExpandHome(path string) (string, error)

ExpandHome expands the path to include the home directory if the path is prefixed with `~`. If it isn't prefixed with `~`, the path is returned as-is. Via https://github.com/mitchellh/go-homedir/blob/master/homedir.go

func FileExists

func FileExists(filename string) bool

FileExists returns whether or not a file exists on the filesystem. We consider any error returned by os.Stat to indicate that the file doesn't exist. We could be specific and use os.IsNotExist(err), but most other errors also indicate that the file isn't there (or isn't available) so we'll just catch them all.

func NormalizeCommand

func NormalizeCommand(commandPath string) (string, error)

func NormalizeFilePath

func NormalizeFilePath(path string) (string, error)

Normalizes a path and returns an clean absolute version. It correctly expands environment variables inside paths, converts "~/" into the users home directory, and replaces "./" with the current working directory.

Types

This section is empty.

Jump to

Keyboard shortcuts

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