Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ibbd-dev/go-rotate-file

文件操作对象,支持自动切割。支持按小时,天,月等方式自动切割文件。
https://github.com/ibbd-dev/go-rotate-file

Last synced: 6 days ago
JSON representation

文件操作对象,支持自动切割。支持按小时,天,月等方式自动切割文件。

Awesome Lists containing this project

README

        

# go-rotate-file

文件操作对象,支持自动切割。

## Install

```sh
go get -u github.com/ibbd-dev/go-rotate-file
```

## Example

```go
package main

import (
"github.com/ibbd-dev/go-rotate-file"
)

func TestWrite(t *testing.T) {
file := rotateFile.Open("/tmp/test-rotate.log")
defer file.Close()

file.SetSuffix(SuffixDay) // 设置文件名后缀
_, err := file.WriteString("hello world")
if err != nil {
panic(err)
}

_, err = file.WriteString("hello world2")
if err != nil {
panic(err)
}
}
```

## TODO

- [ ] 增加目录不存在的检测
- [ ]
- [ ]