Documentation ¶
Overview ¶
file operations (exists, isfile, etc.)
Index ¶
- func Assert(expr bool, msg string)
- func Contains[T comparable](haystack []T, needle T) bool
- func ExecCmd(cmd string) (string, error)
- func Exists(path string) bool
- func Index[T comparable](haystack []T, needle T) int
- func IsDir(path string) bool
- func IsFile(path string) bool
- func IsLink(path string) bool
- func MakeExecutable(fname string) error
- func Remove[T comparable](slice []T, element T) ([]T, bool)
- func WriteSourceToFile(source, fname string) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Assert ¶
Assert mimics assert from other languages. It panics if the expression is false. If msg is given, it is printed as an error message.
func Contains ¶
func Contains[T comparable](haystack []T, needle T) bool
Returns true if the element is found in the slice. Returns false if not found.
func Exists ¶
Returns true if the entry (file, directory, symbolic link, etc.) exists. Returns false if the entry doesn't exist.
func Index ¶
func Index[T comparable](haystack []T, needle T) int
Returns the index of an element. If not found, -1 is returned.
func IsDir ¶
Is it a directory? Returns true for a directory and for a symbolic link pointing on a directory.
func IsFile ¶
Is it a regular file? Returns true for a regular file and for a symbolic link pointing on a regular file.
func MakeExecutable ¶
Make a file executable for the owner. Equivalent of "chmod u+x <file>" . You can also call it on Windows. It won't do anything, but you won't get an error either.
func Remove ¶
func Remove[T comparable](slice []T, element T) ([]T, bool)
Removes the first occurrence of an element from a slice. The length of the returned slice will be one less if the element was found. The original slice will be modified if the element was found, but use the returned slice on the caller side. The returned boolean is true if the element was removed, and false otherwise.
func WriteSourceToFile ¶
Create file and save source code in it. Print an error message if the file exists.
Types ¶
This section is empty.