gnsys

package module
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2024 License: MIT Imports: 9 Imported by: 29

README

Package gnsys

A helper package for filesystem operations

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanDir

func CleanDir(dir string) error

CleanDir removes all files from a directory or creates the directory if it is absent.

func ConvertTilda

func ConvertTilda(path string) (string, error)

ConvertTilda expands paths with `~/` to an actual home directory.

func DirExists added in v0.2.0

func DirExists(path string) (exists bool, empty bool, err error)

DirExists checks if directory exists and if it is empty

func Download added in v0.3.0

func Download(url, destDir string, showProgress bool) (string, error)

Download copies remote file to local drive. It provides the name of downloaded file and error as output.

func FileExists

func FileExists(f string) (bool, error)

FileExists checks if a file exists, and that it is a regular file.

func IsDir added in v0.2.0

func IsDir(path string) bool

func IsFile added in v0.2.0

func IsFile(path string) bool

func MakeDir

func MakeDir(dir string) error

MakeDir a directory out of a given unless it already exists.

func Ping added in v0.3.3

func Ping(host string, seconds int) bool

Ping checks if a server is reachable. Host should be in format "host:port" (eg "google.com:80")

Types

type DirState added in v0.2.4

type DirState int

DirState represents the state of a directory.

const (
	Unknown DirState = iota
	NotDir
	DirAbsent
	DirEmpty
	DirNotEmpty
)

func GetDirState added in v0.2.4

func GetDirState(dir string) DirState

GetDirState returns the state of a directory.

func (DirState) String added in v0.2.4

func (d DirState) String() string

String returns a string representation of the DirState.

Jump to

Keyboard shortcuts

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