github.com/v2pro/plz@v0.0.0-20221028024117-e5f9aec5b631/countlog/output/rotation/archive_by_move.go (about) 1 package rotation 2 3 import "os" 4 5 type ArchiveByMove struct { 6 NamingStrategy NamingStrategy 7 } 8 9 func (strategy *ArchiveByMove) Archive(path string) ([]Archive, error) { 10 newPath, err := strategy.NamingStrategy.NextFile() 11 if err != nil { 12 return nil, err 13 } 14 err = os.Rename(path, newPath) 15 if err != nil { 16 if os.IsNotExist(err) { 17 return nil, nil 18 } 19 return nil, err 20 } 21 return strategy.NamingStrategy.ListFiles() 22 }