fileutil

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateFile

func CreateFile(filePath string) (*os.File, *errors.Error)

CreateFile creates a new file The method returns an errors if there was an issue with creating an new file

func FileExists

func FileExists(filePath string) bool

FileExists checks if a file exists and returns an errors if the file was not found

func OpenFile

func OpenFile(filePath string) (*os.File, *errors.Error)

OpenFile opens a file The method returns an errors if there is an issue with opening the file

func ReadFile

func ReadFile(filePath string) ([]byte, *errors.Error)

ReadFile checks if a file exists and if it does tries to reads the contents of the file and returns the data back The method returns an errors the file does not exist or if there was an errors in reading the contents of the file

func ReadJsonFile

func ReadJsonFile(filePath string, out any) *errors.Error

ReadJsonFile reads a yaml file and puts the contents into the out variables out variable should be a pointer to a valid struct The method returns and errors if reading a file or the unmarshal process fails

func RemoveFile

func RemoveFile(filePath string) *errors.Error

RemoveFile removes files from the provided valid filePath.

func WriteFile

func WriteFile(filePath string, data []byte) *errors.Error

WriteFile creates a new file if the file does not exists and writes data into the file The method returns an errors if there was an issue creating a new file or while writing data into the file

func WriteJSONFile

func WriteJSONFile(filePath string, in any) *errors.Error

WriteJSONFile encodes the data from an input interface into json format and writes the data into a file The in interface should be an address to a valid struct The method returns an errors if there is an errors with the json encode or with writing to the file

Types

This section is empty.

Jump to

Keyboard shortcuts

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