Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ibbd-dev/go-rotate-file
文件操作对象,支持自动切割。支持按小时,天,月等方式自动切割文件。
https://github.com/ibbd-dev/go-rotate-file
Last synced: 6 days ago
JSON representation
文件操作对象,支持自动切割。支持按小时,天,月等方式自动切割文件。
- Host: GitHub
- URL: https://github.com/ibbd-dev/go-rotate-file
- Owner: ibbd-dev
- License: mit
- Created: 2016-11-09T09:59:33.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2016-11-24T07:27:33.000Z (almost 8 years ago)
- Last Synced: 2024-06-19T11:35:14.237Z (5 months ago)
- Language: Go
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-rotate-file
文件操作对象,支持自动切割。
## Install
```sh
go get -u github.com/ibbd-dev/go-rotate-file
```## Example
```go
package mainimport (
"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
- [ ] 增加目录不存在的检测
- [ ]
- [ ]