zos

package
v0.9.6 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateWith added in v0.3.0

func CreateWith(path string, handler FileHandler) (err error)

Create a file and use it inside a closure. Will automatically close the file after the closure completes and remove the corrupt file if an error is thrown.

func CreateWithTemp added in v0.3.0

func CreateWithTemp(path string, handler FileHandler) error

Like CreateWith, but will create a temporary file and rename it to the final path once the file has been written successfully. If an error occurs, the temp file will be removed.

func Exists

func Exists(path string) bool

Determine if a path exists or not

func IsDir added in v0.8.1

func IsDir(path string) bool

Returns true if a path exists and is a directory. It still returns false even if the path doesn't exist.

func OpenFirst added in v0.9.6

func OpenFirst(paths ...string) (f *os.File, err error)

Open the first existing path in a list of paths

func ReadLines added in v0.9.2

func ReadLines(path string) (lines []string, err error)

Read all lines from a text file into a slice

func ReadLinesFromFile added in v0.9.6

func ReadLinesFromFile(f *os.File) (lines []string, err error)

Read all lines from an open text file into a slice

Types

type FileHandler added in v0.3.0

type FileHandler = func(f *os.File) error

Jump to

Keyboard shortcuts

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