path

package
v0.0.0-...-5a547ea Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2018 License: MIT Imports: 10 Imported by: 7

README

path

file.go

CreateFile(path string) error
  • path the path of file
AppendToFile(path string, s ...string) error
  • path the path of file
  • s the content strings
OverwriteFile(path string, s ...string) error
  • path the path of file
  • s the content strings
ReadFile(path string) (s string,err error)
  • path the path of file
  • s the content of the file
RemoveFile(path string, dir bool) error
  • path the path of file or directory
  • dir if the path directory

home.go

HomeDir() (home string,err error)
  • home the path to the user's home directory

path.go

IsExist(path string) (ok bool, err error)
  • path the path of file or directory
  • ok exists the path of file or directory
  • err if not match not exist errors
MustExist(_path string) (ok bool)
  • ok exists the path of file or directory
Ensure(path string, dir bool) error
  • path the path of file or directory
  • dir the path is directory
ExecPath() (path string)
  • path the file path of program
ExecDir() (path string)
  • path the directory path of program

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendToFile

func AppendToFile(path string, s ...string) error

AppendToFile appends the contents of s to the path file, each s ends with new line.

func CreateFile

func CreateFile(path string) error

CreateFile creates the path file with mode 0666 (before umask), truncating it if it already exists. If there is an error, it will be of type *PathError.

func Ensure

func Ensure(_path string, dir bool) error

Ensure returns an error if the path of file or directory(dir is true) isn't existed or catches other error.

func ExecDir

func ExecDir() string

ExecDir returns the directory path of the command-line program.

func ExecPath

func ExecPath() string

ExecPath returns the path of the command-line program.

func HomeDir

func HomeDir() (string, error)

HomeDir returns the path to the user's home directory (if they have one).

func IsExist

func IsExist(_path string) (ok bool, err error)

IsExist returns boolean indicating whether the path of file or directory already exists. Returns an unknown error if not match some syscall errors.

func MustExist

func MustExist(_path string) bool

MustExist returns a boolean, it true if the path of file or directory already exists.

func OverwriteFile

func OverwriteFile(path string, s ...string) error

OverwriteFile overwrite the path file with the contents of s, each s ends with a new line.

func ReadFile

func ReadFile(path string) (string, error)

ReadFile reads the contents from the path file.

func RemoveFile

func RemoveFile(path string, dir bool) error

RemoveFile if dir then removes path and any children it contains, otherwise then removes the path file or directory.

Types

This section is empty.

Jump to

Keyboard shortcuts

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