Skip to content

Latest commit

 

History

History
42 lines (30 loc) · 587 Bytes

README.md

File metadata and controls

42 lines (30 loc) · 587 Bytes

go-rotate-file

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

Install

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

Example

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

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