file

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Basename

func Basename(fp string) string

get filepath base name

func Close

func Close(fd *os.File) error

close fd

func Create

func Create(name string) (*os.File, error)

create one file

func Dir

func Dir(fp string) string

get filepath dir name

func DirsUnder

func DirsUnder(dirPath string) ([]string, error)

list dirs under dirPath

func EnsureDir

func EnsureDir(fp string) error

mkdir dir if not exist

func EnsureDirRW

func EnsureDirRW(dataDir string) error

ensure the datadir and make sure it's rw-able

func Ext

func Ext(fp string) string

func FileMTime

func FileMTime(fp string) (int64, error)

get file modified time

func FileSize

func FileSize(fp string) (int64, error)

get file size as how many bytes

func FilesUnder

func FilesUnder(dirPath string) ([]string, error)

list files under dirPath

func InsureDir

func InsureDir(fp string) error

func IsExist

func IsExist(fp string) bool

IsExist checks whether a file or directory exists. It returns false when the file or directory does not exist.

func IsFile

func IsFile(fp string) bool

IsFile checks whether the path is a file, it returns false when it's a directory or does not exist.

func MustOpenLogFile

func MustOpenLogFile(fp string) *os.File

func ReadLine

func ReadLine(r *bufio.Reader) ([]byte, error)

func RealPath

func RealPath(fp string) (string, error)

get absolute filepath, based on built executable file

func Remove

func Remove(name string) error

remove one file

func Rename

func Rename(src string, target string) error

rename file name

func SearchFile

func SearchFile(filename string, paths ...string) (fullPath string, err error)

Search a file in paths. this is often used in search config file in /etc ~/

func SelfDir

func SelfDir() string

SelfDir gets compiled executable file directory

func SelfPath

func SelfPath() string

SelfPath gets compiled executable file absolute path

func ToBytes

func ToBytes(filePath string) ([]byte, error)

func ToInt64

func ToInt64(filePath string) (int64, error)

func ToString

func ToString(filePath string) (string, error)

func ToTrimString

func ToTrimString(filePath string) (string, error)

func ToUint64

func ToUint64(filePath string) (uint64, error)
func Unlink(fp string) error

delete file

func WriteBytes

func WriteBytes(filePath string, b []byte) (n int, err error)

func WriteString

func WriteString(filePath string, s string) (int, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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