Documentation
¶
Overview ¶
Package osext provides some helpful os functions.
Index ¶
- Variables
- func Caller(steps int) string
- func DirExists(dir string) error
- func IsDocker() bool
- func IsInteractive() bool
- func IsPathError(err error) bool
- func IsRoot() bool
- func IsSame(path1, path2 string) (bool, error)
- func MoveFile(src string, fs fsadapter.FS, dst string) error
- func UnGZIP(r io.Reader) (*os.File, error)
- type Error
- type Namer
- type ReadSeekCloseNamer
- type RemoveWrapper
Constants ¶
This section is empty.
Variables ¶
var ErrNotADir = errors.New("not a directory")
ErrNotADir is returned when the path is not a directory.
Functions ¶
func DirExists ¶
DirExists checks if the directory exists and is a directory. It will return an error if the path does not exist, and if the path is not a directory, ErrNotADir will be returned.
func IsDocker ¶ added in v3.0.7
func IsDocker() bool
IsDocker returns true if the process is running in a docker container.
func IsInteractive ¶ added in v3.0.7
func IsInteractive() bool
isInteractive returns true if the program is running in the interactive terminal.
func IsPathError ¶
IsPathError reports whether the error is an fs.PathError.
func MoveFile ¶
MoveFile moves a file from src to dst. If dst already exists, it will be overwritten.
Adopted solution from https://stackoverflow.com/questions/50740902/move-a-file-to-a-different-drive-with-go
Types ¶
type Namer ¶
type Namer interface { // Name should return the name of the file. *os.File implements this // interface. Name() string }
Namer is an interface that allows us to get the name of the file.
type ReadSeekCloseNamer ¶
type ReadSeekCloseNamer interface { io.ReadSeekCloser Name() string }
ReadSeekCloseNamer is an io.ReadSeekCloser that also has a Name method.
func RemoveOnClose ¶
func RemoveOnClose(r *os.File) ReadSeekCloseNamer
RemoveOnClose wraps an *os.File and removes it when it is closed. The filename must be given.
type RemoveWrapper ¶
type RemoveWrapper struct { io.ReadSeekCloser // contains filtered or unexported fields }
RemoveWrapper wraps an io.ReadSeekCloser and removes the file when it is closed.
func (RemoveWrapper) Close ¶
func (r RemoveWrapper) Close() error
func (RemoveWrapper) Name ¶
func (r RemoveWrapper) Name() string