utils

package
v2.0.37 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs(path string) (abs string, err error)

func Basename

func Basename(path string, ext string) string

func CreateEmptyFile

func CreateEmptyFile(path string) (err error)

func CreateEmptyFileIfNotExists

func CreateEmptyFileIfNotExists(path string) (err error)

func CygwinizePath

func CygwinizePath(path string) string

func Dir

func Dir(path string) string

func ErrorIf

func ErrorIf(condition bool, message string) error
func EvalSymlinks(path string) (string, error)

func Executable

func Executable() (exe string)

func Filename

func Filename(path string) string

func FilterDirectories

func FilterDirectories(paths []string) []string

func Get

func Get[E comparable](v E, fallbacks ...E) E

func GetCygwinAwareHomeDir

func GetCygwinAwareHomeDir() string

GetCygpathHomeDir returns the user's ~/ dir from the cygpath command. If cygpath doesn't exist (either not on Windows or Cygwin is not installed) then the normal $USERPROFILE or /Users/<username> is returned. This method is only used to determine the location of the user's rc file for setup, in all other cases the user's home dir is the normal one. Note: on windows in powershell, this resolves to the cygwin home dir (unexpectedly)

func GetIndex

func GetIndex[S ~[]E, E any](s S, index int, fallback E) E

func GetShellHomeDir

func GetShellHomeDir() string

func GetTerminalType

func GetTerminalType() string

func GetUserHomeDir

func GetUserHomeDir() string

func Getwd

func Getwd() string

func Join

func Join(paths ...string) string

func OpenFileInDefaultApp

func OpenFileInDefaultApp(path string) (err error)

func PanicIfError

func PanicIfError(err error)

func PanicIfFalse

func PanicIfFalse(condition bool, message string)

func PanicIfPathDoesNotExist

func PanicIfPathDoesNotExist(path string)

func PanicIfPathExists

func PanicIfPathExists(path string)

func PanicIfTrue

func PanicIfTrue(condition bool, message string)

func PathExists

func PathExists(filename string) bool

func PathIsDir

func PathIsDir(filename string) bool

func PathIsFile

func PathIsFile(filename string) bool

func Rel

func Rel(basepath string, targpath string) (string, error)

func SafeWriteTemplateToFile

func SafeWriteTemplateToFile(t *template.Template, path string, vars map[string]interface{}) (err error)

func SortKeys

func SortKeys[M ~map[K]V, K cmp.Ordered, V any](m M) []K

func Ternary

func Ternary[T any](cond bool, a T, b T) T

func ToSlash

func ToSlash(path string) string

func WriteTemplateToFile

func WriteTemplateToFile(tmpl *template.Template, path string, vars map[string]interface{}) (err error)

func WriteTemplateToString

func WriteTemplateToString(tmpl *template.Template, vars map[string]interface{}) (string, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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