github.com/orangebees/go-oneutils@v0.0.10/GlobalStore/FileInfoPool.go (about) 1 package GlobalStore 2 3 import "sync" 4 5 var poolFileInfo = sync.Pool{ 6 New: func() any { 7 return &FileInfo{} 8 }, 9 } 10 11 func (fi *FileInfo) Reset() { 12 fi.CheckedAt = 0 13 fi.Mode = 0 14 fi.Size = 0 15 fi.Integrity = EmptyString 16 } 17 func AcquireFileInfo() *FileInfo { 18 return poolFileInfo.Get().(*FileInfo) 19 } 20 21 func ReleaseFileInfo(fi *FileInfo) { 22 fi.Reset() 23 poolFileInfo.Put(fi) 24 }