utils

package
v2.0.28 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateEmptyFile

func CreateEmptyFile(path string) (err error)

func CreateEmptyFileIfNotExists added in v2.0.28

func CreateEmptyFileIfNotExists(path string) (err error)

func CygwinizePath added in v2.0.28

func CygwinizePath(path string) string

func ErrorIf added in v2.0.28

func ErrorIf(condition bool, message string) error

func Executable

func Executable() (exe string)

func FileBase

func FileBase(path string, ext string) string

func FilterDirectories

func FilterDirectories(paths []string) []string

func Get

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

func GetCygpathHomeDir added in v2.0.28

func GetCygpathHomeDir() 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.

func GetIndex

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

func GetUserHomeDir added in v2.0.25

func GetUserHomeDir() string

func Getwd

func Getwd() string

func MakeDirnameAvailableValidator

func MakeDirnameAvailableValidator(parentDir string) func(string) error

func OpenFileInDefaultApp added in v2.0.28

func OpenFileInDefaultApp(path string) 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 SafeWriteTemplateToFile added in v2.0.28

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

func SortKeys added in v2.0.28

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

func WriteTemplateToFile added in v2.0.28

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

func WriteTemplateToString added in v2.0.28

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