file

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyFile

func CopyFile(OldPath, NewPath string) error

CopyFile :Copy a file to the given path @params OldPath : File path to be copied @params NewPath : File path to copy to @return: Return nil if the copy is successful, otherwise return an error message. @author: Yu.

func Exists

func Exists(path string) bool

Exists : Determines whether the file or folder exists @params path: @return: Return true if the given path exists, false otherwise @author: Yu.

func ImgFileToB64

func ImgFileToB64(path string) (img string, err error)

ImgFileToB64 : Convert the image to base64 encoding @author: Yu.

func IsDir

func IsDir(path string) bool

IsDir : Determine whether the given path is a folder @params path: @return: Return true if the given path is a folder, false otherwise @author: Yu.

func IsFile

func IsFile(path string) bool

IsFile : Determine whether the given path is a file @params path: @return: Return true if the given path is a file, false otherwise @author: Yu.

func Parent

func Parent(dir string) (string, error)

Parent : Gets the upper path of the given path @params dir: @return: If the given path is a normal folder path, return the upper-level path, otherwise the file path error exception message is raised. @author: Yu.

func Size

func Size(file string, ut Unit) (int64, error)

Size : Calculate the size of the file @params file: file @params ut: unit @return: Returns the size of the file in the specified units @author: Yu.

func Split

func Split(path string) []string

Split : Cut the given path into folders and file names @params path: @return: The return value is a slice type, with the first element representing the file path and the second element representing the file name identifier. @author: Yu.

Types

type Unit

type Unit int
const (
	Byte Unit = iota + 1
	KB
	MB
	GB
	TB
)

Jump to

Keyboard shortcuts

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