toolkits

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2024 License: MIT Imports: 14 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 Contains

func Contains(sl []interface{}, v interface{}) bool

func ContainsInt

func ContainsInt(sl []int, v int) bool

func ContainsInt64

func ContainsInt64(sl []int64, v int64) bool

func ContainsString

func ContainsString(sl []string, v string) bool

func ConvStrToBool

func ConvStrToBool(s string) bool

func ConvStrToFloat

func ConvStrToFloat(s string) float64

func ConvStrToInt

func ConvStrToInt(s string) int

func ConvStrToInt64

func ConvStrToInt64(s string) int64

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 Download

func Download(toFile, url string) error

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 GetFilePos

func GetFilePos(LastSQLError string) map[string]string

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 IsIP

func IsIP(ip string) (b bool)

func Merge

func Merge(slice1, slice2 []interface{}) (c []interface{})

SliceMerge merges interface slices to one slice.

func MergeInt

func MergeInt(slice1, slice2 []int) (c []int)

func MergeInt64

func MergeInt64(slice1, slice2 []int64) (c []int64)

func MergeString

func MergeString(slice1, slice2 []string) (c []string)

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 SumFloat64

func SumFloat64(s []float64) (sum float64)

func SumInt

func SumInt(s []int) (sum int)

func SumInt64

func SumInt64(s []int64) (sum int64)

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 UniqueInt

func UniqueInt(s []int) []int

func UniqueInt64

func UniqueInt64(s []int64) []int64

func UniqueString

func UniqueString(s []string) []string
func Unlink(fp string) error

delete file

func WriteBytes

func WriteBytes(filePath string, b []byte) (int, 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