file

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2023 License: Apache-2.0 Imports: 6 Imported by: 6

Documentation

Overview

Package for working with files

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyFile

func CopyFile(src, dst string) (int64, error)

CopyFile It copies a file from one location to another - src: the source file - dst: the destination file - returns: the number of bytes copied and an error if there was a problem copying the file

func DownloadFile

func DownloadFile(url string, filepath string) error

DownloadFile Download a file from a URL and save it to a filepath - url: the URL of the file to download - filepath: the path to save the file to - returns: an error if there was a problem downloading the file

func FileExists

func FileExists(path string) bool

FileExists If the file exists, return true, otherwise return false - path: the path to the file - returns: true if the file exists, otherwise false

func ReadFile added in v0.2.2

func ReadFile(sourceFile string) ([]byte, error)

ReadFile Read the contents of a file into a byte array - sourceFile: the path to the file to read - returns: the contents of the file as a byte array and an error if there was a problem reading the file

func ReadFileToString

func ReadFileToString(sourceFile string) (string, error)

ReadFileToString Read the contents of a file into a string - sourceFile: the path to the file to read - returns: the contents of the file as a string and an error if there was a problem reading the file

func SaveStringToFile

func SaveStringToFile(filename string, content string) error

SaveStringToFile It creates a directory if it doesn't exist, then creates a file if it doesn't exist, then writes the content to the file - filename: the path to the file to write to - content: the content to write to the file - returns: an error if there was a problem writing 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