utils

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2020 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BufioRead

func BufioRead(name string)

读取文件, 用bufio读取文件

func CreateDir

func CreateDir(_dir string) (err error)

CreateDir 判断文件夹是否存在,不存在就创建一个

func FileRead

func FileRead(name string)

读取文件, 用os读取文件

func GetAllFile

func GetAllFile(path string) (fileName []string, err error)

****读文件********************************************************

func main() {
   Ioutil("mytestfile.txt")
   OsIoutil("mytestfile.txt")
   FileRead("mytestfile.txt")
   BufioRead("mytestfile.txt")
   GetAllFile("temp/btc_usdt/")
   ReadWithBufByLine("kline.json")
   WriteByLine([]string,"temp/btc_usdt/")
}

****************************************************************** 获取目录下所有文件

func GetRunPath

func GetRunPath() string

获取当前项目执行目录

func GetZeroForToday

func GetZeroForToday() (t int64)

取今天的零点的时间戳

func Ioutil

func Ioutil(name string) string

读取文件, 用Ioutils读取文件

func Ioutils

func Ioutils(name string) string

读取文件, 用Ioutils读取文件,一行一行的读取

func PathExists

func PathExists(path string) bool

pathExists 判断文件夹是否存在,存在返回true,不存在返回false

func ReadWithBufByLine

func ReadWithBufByLine(path string) string

读取文件, 用bufio读取文件,一行一行的读取

func StringToTimestamp

func StringToTimestamp(str string) int64

日期转时间戳

func TimeToDateSlice

func TimeToDateSlice(fromTime, toTime int64) (ts []string)

把指定的开始和结束时间戳,转换为 日期的数组

func TsToDate

func TsToDate(i int64) string

时间戳int64转日期

func WriteByLine

func WriteByLine(line string, filePath string) (err error)

写文件,指定某一行追加写入

func WriteWithBufio

func WriteWithBufio(name, content string)

使用bufio包中Writer对象的相关方法进行数据的写入

func WriteWithFileWrite

func WriteWithFileWrite(name, content string)

使用os.OpenFile()相关函数打开文件对象,并使用文件对象的相关方法进行文件写入操作 清空一次文件

func WriteWithIo

func WriteWithIo(name, content string)

使用io.WriteString()函数进行数据的写入

func WriteWithIoutil

func WriteWithIoutil(name, content string) error

使用ioutil.WriteFile方式写入文件,是将[]byte内容写入文件,如果content字符串中没有换行符的话,默认就不会有换行符

Types

This section is empty.

Jump to

Keyboard shortcuts

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