file

package
v0.0.0-...-59ce246 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Append

func Append(data string, dst string) (err error)

Append appends a string to the end of file dst.

func Copy

func Copy(src, dst string) (err error)

Copy copies a file from src to dst, creating directories for the destination if needed. dst is assumed to be a file and not a directory. Will preserve permissions.

func CopyAndChangeMode

func CopyAndChangeMode(src, dst string, dirmode os.FileMode, filemode os.FileMode) (err error)

CopyAndChangeMode copies a file from src to dst, creating directories with the given access rights for the destination if needed. dst is assumed to be a file and not a directory. Will change the permissions to the given value.

func CopyResourceFile

func CopyResourceFile(srcFS fs.FS, srcFile, dst string, dirmode os.FileMode, filemode os.FileMode) error

CopyResourceFile copies a file from an embedded binary resource file.

func Create

func Create(dst string, perm os.FileMode) (err error)

Create creates a new file with the provided Unix permissions

func DirExists

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

DirExists returns true if the directory exists, false otherwise.

func GenerateSHA1

func GenerateSHA1(path string) (hash string, err error)

GenerateSHA1 calculates a sha1 of a file

func GenerateSHA256

func GenerateSHA256(path string) (hash string, err error)

GenerateSHA256 calculates a sha256 of a file

func GetAbsPathWithBase

func GetAbsPathWithBase(baseDirPath, inputPath string) string

GetAbsPathWithBase converts 'inputPath' to an absolute path starting from 'baseDirPath', but only if it wasn't an absolute path in the first place.

func IsDir

func IsDir(filePath string) (isDir bool, err error)

IsDir check if a given file path is a directory.

func IsFile

func IsFile(path string) (isFile bool, err error)

IsFile returns true if the provided path is a file.

func Move

func Move(src, dst string) (err error)

Move moves a file from src to dst. Will preserve permissions.

func PathExists

func PathExists(path string) (exists bool, err error)

PathExists returns true if the path exists, false otherwise.

func ReadLines

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

readLines reads file under path and returns lines as strings and any error encountered

func RemoveFileIfExists

func RemoveFileIfExists(path string) (err error)

RemoveFileIfExists will delete a file if it exists on disk.

func Write

func Write(data string, dst string) (err error)

Write writes a string to the file dst.

func WriteLines

func WriteLines(dataLines []string, destinationPath string) (err error)

WriteLines writes each string to the same file, separated by lineSeparator (e.g. "\n").

Types

This section is empty.

Jump to

Keyboard shortcuts

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