github.com/Asutorufa/yuhaiin@v0.3.6-0.20240502055049-7984da7023a0/pkg/log/writer_test.go (about) 1 package log 2 3 import ( 4 "os" 5 "sort" 6 "strings" 7 "testing" 8 9 "github.com/Asutorufa/yuhaiin/pkg/utils/assert" 10 ) 11 12 func TestExt(t *testing.T) { 13 dir := "/home/dev/yuhaiin.log" 14 15 t.Log(NewPath(dir).FullPath("xxx")) 16 17 f, err := os.ReadDir("/home/asutorufa/.config/yuhaiin/log") 18 assert.NoError(t, err) 19 20 sort.Slice(f, func(i, j int) bool { return f[i].Name() > f[j].Name() }) 21 22 count := 0 23 for _, v := range f { 24 if !(strings.HasPrefix(v.Name(), "yuhaiin_") && strings.HasSuffix(v.Name(), "log")) { 25 continue 26 } 27 count++ 28 29 if count <= 5 { 30 continue 31 } 32 33 t.Log(v.Name(), count) 34 } 35 }